<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">-- (c) The University of Glasgow 2006</span><span>
</span><span id="line-2"></span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE ScopedTypeVariables, PatternSynonyms #-}</span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-5"></span><span class="hs-pragma">{-# LANGUAGE DeriveFunctor #-}</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Core.Unify</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-8"></span><span>        </span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTy"><span class="hs-identifier">tcMatchTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTyKi"><span class="hs-identifier">tcMatchTyKi</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-9"></span><span>        </span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTys"><span class="hs-identifier">tcMatchTys</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTyKis"><span class="hs-identifier">tcMatchTyKis</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-10"></span><span>        </span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTyX"><span class="hs-identifier">tcMatchTyX</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTysX"><span class="hs-identifier">tcMatchTysX</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTyKisX"><span class="hs-identifier">tcMatchTyKisX</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-11"></span><span>        </span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTyX_BM"><span class="hs-identifier">tcMatchTyX_BM</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#ruleMatchTyKiX"><span class="hs-identifier">ruleMatchTyKiX</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-12"></span><span>
</span><span id="line-13"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Rough matching</span></span><span>
</span><span id="line-14"></span><span>        </span><span class="annot"><a href="GHC.Core.Unify.html#roughMatchTcs"><span class="hs-identifier">roughMatchTcs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#instanceCantMatch"><span class="hs-identifier">instanceCantMatch</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-15"></span><span>        </span><span class="annot"><a href="GHC.Core.Unify.html#typesCantMatch"><span class="hs-identifier">typesCantMatch</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-16"></span><span>
</span><span id="line-17"></span><span>        </span><span class="hs-comment">-- Side-effect free unification</span><span>
</span><span id="line-18"></span><span>        </span><span class="annot"><a href="GHC.Core.Unify.html#tcUnifyTy"><span class="hs-identifier">tcUnifyTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#tcUnifyTyKi"><span class="hs-identifier">tcUnifyTyKi</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#tcUnifyTys"><span class="hs-identifier">tcUnifyTys</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#tcUnifyTyKis"><span class="hs-identifier">tcUnifyTyKis</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-19"></span><span>        </span><span class="annot"><a href="GHC.Core.Unify.html#tcUnifyTysFG"><span class="hs-identifier">tcUnifyTysFG</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#tcUnifyTyWithTFs"><span class="hs-identifier">tcUnifyTyWithTFs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>        </span><span class="annot"><a href="GHC.Core.Unify.html#BindFlag"><span class="hs-identifier">BindFlag</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>        </span><span class="annot"><a href="GHC.Core.Unify.html#UnifyResult"><span class="hs-identifier">UnifyResult</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UnifyResultM"><span class="hs-identifier">UnifyResultM</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span>        </span><span class="hs-comment">-- Matching a type against a lifted type (coercion)</span><span>
</span><span id="line-24"></span><span>        </span><span class="annot"><a href="GHC.Core.Unify.html#liftCoMatch"><span class="hs-identifier">liftCoMatch</span></a></span><span>
</span><span id="line-25"></span><span>   </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-30"></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier">Name</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>     </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#getTvSubstEnv"><span class="hs-identifier">getTvSubstEnv</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html"><span class="hs-identifier">GHC.Core.Coercion</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#getCvSubstEnv"><span class="hs-identifier">getCvSubstEnv</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html"><span class="hs-identifier">GHC.Core.TyCon</span></a></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html"><span class="hs-identifier">GHC.Core.TyCo.Rep</span></a></span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.FVs.html"><span class="hs-identifier">GHC.Core.TyCo.FVs</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfCoList"><span class="hs-identifier">tyCoVarsOfCoList</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.FVs.html#tyCoFVsOfTypes"><span class="hs-identifier">tyCoFVsOfTypes</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html"><span class="hs-identifier">GHC.Core.TyCo.Subst</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#mkTvSubst"><span class="hs-identifier">mkTvSubst</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html"><span class="hs-identifier">GHC.Utils.FV</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier">FV</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#fvVarSet"><span class="hs-identifier">fvVarSet</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#fvVarList"><span class="hs-identifier">fvVarList</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Pair.html"><span class="hs-identifier">GHC.Data.Pair</span></a></span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html"><span class="hs-identifier">GHC.Types.Unique.FM</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html"><span class="hs-identifier">GHC.Types.Unique.Set</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.Exts.html#"><span class="hs-identifier">GHC.Exts</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><span class="hs-identifier">oneShot</span></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Applicative.html#"><span class="hs-identifier">Control.Applicative</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#empty"><span class="hs-identifier">empty</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../base/src/Control.Applicative.html#"><span class="hs-identifier">Control.Applicative</span></a></span><span>
</span><span id="line-52"></span><span>
</span><span id="line-53"></span><span class="hs-comment">{-

Unification is much tricker than you might think.

1. The substitution we generate binds the *template type variables*
   which are given to us explicitly.

2. We want to match in the presence of foralls;
        e.g     (forall a. t1) ~ (forall b. t2)

   That is what the RnEnv2 is for; it does the alpha-renaming
   that makes it as if a and b were the same variable.
   Initialising the RnEnv2, so that it can generate a fresh
   binder when necessary, entails knowing the free variables of
   both types.

3. We must be careful not to bind a template type variable to a
   locally bound variable.  E.g.
        (forall a. x) ~ (forall b. b)
   where x is the template type variable.  Then we do not want to
   bind x to a/b!  This is a kind of occurs check.
   The necessary locals accumulate in the RnEnv2.

Note [tcMatchTy vs tcMatchTyKi]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This module offers two variants of matching: with kinds and without.
The TyKi variant takes two types, of potentially different kinds,
and matches them. Along the way, it necessarily also matches their
kinds. The Ty variant instead assumes that the kinds are already
eqType and so skips matching up the kinds.

How do you choose between them?

1. If you know that the kinds of the two types are eqType, use
   the Ty variant. It is more efficient, as it does less work.

2. If the kinds of variables in the template type might mention type families,
   use the Ty variant (and do other work to make sure the kinds
   work out). These pure unification functions do a straightforward
   syntactic unification and do no complex reasoning about type
   families. Note that the types of the variables in instances can indeed
   mention type families, so instance lookup must use the Ty variant.

   (Nothing goes terribly wrong -- no panics -- if there might be type
   families in kinds in the TyKi variant. You just might get match
   failure even though a reducing a type family would lead to success.)

3. Otherwise, if you're sure that the variable kinds do not mention
   type families and you're not already sure that the kind of the template
   equals the kind of the target, then use the TyKi version.
-}</span><span>
</span><span id="line-104"></span><span>
</span><span id="line-105"></span><span class="hs-comment">-- | @tcMatchTy t1 t2@ produces a substitution (over fvs(t1))</span><span>
</span><span id="line-106"></span><span class="hs-comment">-- @s@ such that @s(t1)@ equals @t2@.</span><span>
</span><span id="line-107"></span><span class="hs-comment">-- The returned substitution might bind coercion variables,</span><span>
</span><span id="line-108"></span><span class="hs-comment">-- if the variable is an argument to a GADT constructor.</span><span>
</span><span id="line-109"></span><span class="hs-comment">--</span><span>
</span><span id="line-110"></span><span class="hs-comment">-- Precondition: typeKind ty1 `eqType` typeKind ty2</span><span>
</span><span id="line-111"></span><span class="hs-comment">--</span><span>
</span><span id="line-112"></span><span class="hs-comment">-- We don't pass in a set of &quot;template variables&quot; to be bound</span><span>
</span><span id="line-113"></span><span class="hs-comment">-- by the match, because tcMatchTy (and similar functions) are</span><span>
</span><span id="line-114"></span><span class="hs-comment">-- always used on top-level types, so we can bind any of the</span><span>
</span><span id="line-115"></span><span class="hs-comment">-- free variables of the LHS.</span><span>
</span><span id="line-116"></span><span class="hs-comment">-- See also Note [tcMatchTy vs tcMatchTyKi]</span><span>
</span><span id="line-117"></span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTy"><span class="hs-identifier hs-type">tcMatchTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-118"></span><span id="tcMatchTy"><span class="annot"><span class="annottext">tcMatchTy :: Type -&gt; Type -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcMatchTy"><span class="hs-identifier hs-var hs-var">tcMatchTy</span></a></span></span><span> </span><span id="local-6989586621680854338"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854338"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621680854337"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854337"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcMatchTys"><span class="hs-identifier hs-var">tcMatchTys</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854338"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854337"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-119"></span><span>
</span><span id="line-120"></span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTyX_BM"><span class="hs-identifier hs-type">tcMatchTyX_BM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#BindFlag"><span class="hs-identifier hs-type">BindFlag</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-121"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-122"></span><span id="tcMatchTyX_BM"><span class="annot"><span class="annottext">tcMatchTyX_BM :: (OutTyVar -&gt; BindFlag)
-&gt; TCvSubst -&gt; Type -&gt; Type -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcMatchTyX_BM"><span class="hs-identifier hs-var hs-var">tcMatchTyX_BM</span></a></span></span><span> </span><span id="local-6989586621680854335"><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854335"><span class="hs-identifier hs-var">bind_me</span></a></span></span><span> </span><span id="local-6989586621680854334"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854334"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854333"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854333"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621680854332"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854332"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-123"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; BindFlag)
-&gt; Bool -&gt; TCvSubst -&gt; [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tc_match_tys_x"><span class="hs-identifier hs-var">tc_match_tys_x</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854335"><span class="hs-identifier hs-var">bind_me</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854334"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854333"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854332"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-124"></span><span>
</span><span id="line-125"></span><span class="hs-comment">-- | Like 'tcMatchTy', but allows the kinds of the types to differ,</span><span>
</span><span id="line-126"></span><span class="hs-comment">-- and thus matches them as well.</span><span>
</span><span id="line-127"></span><span class="hs-comment">-- See also Note [tcMatchTy vs tcMatchTyKi]</span><span>
</span><span id="line-128"></span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTyKi"><span class="hs-identifier hs-type">tcMatchTyKi</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-129"></span><span id="tcMatchTyKi"><span class="annot"><span class="annottext">tcMatchTyKi :: Type -&gt; Type -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcMatchTyKi"><span class="hs-identifier hs-var hs-var">tcMatchTyKi</span></a></span></span><span> </span><span id="local-6989586621680854330"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854330"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621680854329"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854329"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-130"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; BindFlag)
-&gt; Bool -&gt; [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tc_match_tys"><span class="hs-identifier hs-var">tc_match_tys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BindFlag -&gt; OutTyVar -&gt; BindFlag
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#BindMe"><span class="hs-identifier hs-var">BindMe</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854330"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854329"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-131"></span><span>
</span><span id="line-132"></span><span class="hs-comment">-- | This is similar to 'tcMatchTy', but extends a substitution</span><span>
</span><span id="line-133"></span><span class="hs-comment">-- See also Note [tcMatchTy vs tcMatchTyKi]</span><span>
</span><span id="line-134"></span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTyX"><span class="hs-identifier hs-type">tcMatchTyX</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>            </span><span class="hs-comment">-- ^ Substitution to extend</span><span>
</span><span id="line-135"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>                </span><span class="hs-comment">-- ^ Template</span><span>
</span><span id="line-136"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>                </span><span class="hs-comment">-- ^ Target</span><span>
</span><span id="line-137"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-138"></span><span id="tcMatchTyX"><span class="annot"><span class="annottext">tcMatchTyX :: TCvSubst -&gt; Type -&gt; Type -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcMatchTyX"><span class="hs-identifier hs-var hs-var">tcMatchTyX</span></a></span></span><span> </span><span id="local-6989586621680854325"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854325"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854324"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854324"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621680854323"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854323"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-139"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; BindFlag)
-&gt; Bool -&gt; TCvSubst -&gt; [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tc_match_tys_x"><span class="hs-identifier hs-var">tc_match_tys_x</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BindFlag -&gt; OutTyVar -&gt; BindFlag
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#BindMe"><span class="hs-identifier hs-var">BindMe</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854325"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854324"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854323"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-140"></span><span>
</span><span id="line-141"></span><span class="hs-comment">-- | Like 'tcMatchTy' but over a list of types.</span><span>
</span><span id="line-142"></span><span class="hs-comment">-- See also Note [tcMatchTy vs tcMatchTyKi]</span><span>
</span><span id="line-143"></span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTys"><span class="hs-identifier hs-type">tcMatchTys</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>         </span><span class="hs-comment">-- ^ Template</span><span>
</span><span id="line-144"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>         </span><span class="hs-comment">-- ^ Target</span><span>
</span><span id="line-145"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-comment">-- ^ One-shot; in principle the template</span><span>
</span><span id="line-146"></span><span>                             </span><span class="hs-comment">-- variables could be free in the target</span><span>
</span><span id="line-147"></span><span id="tcMatchTys"><span class="annot"><span class="annottext">tcMatchTys :: [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcMatchTys"><span class="hs-identifier hs-var hs-var">tcMatchTys</span></a></span></span><span> </span><span id="local-6989586621680854322"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854322"><span class="hs-identifier hs-var">tys1</span></a></span></span><span> </span><span id="local-6989586621680854321"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854321"><span class="hs-identifier hs-var">tys2</span></a></span></span><span>
</span><span id="line-148"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; BindFlag)
-&gt; Bool -&gt; [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tc_match_tys"><span class="hs-identifier hs-var">tc_match_tys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BindFlag -&gt; OutTyVar -&gt; BindFlag
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#BindMe"><span class="hs-identifier hs-var">BindMe</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854322"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854321"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-149"></span><span>
</span><span id="line-150"></span><span class="hs-comment">-- | Like 'tcMatchTyKi' but over a list of types.</span><span>
</span><span id="line-151"></span><span class="hs-comment">-- See also Note [tcMatchTy vs tcMatchTyKi]</span><span>
</span><span id="line-152"></span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTyKis"><span class="hs-identifier hs-type">tcMatchTyKis</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>         </span><span class="hs-comment">-- ^ Template</span><span>
</span><span id="line-153"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>         </span><span class="hs-comment">-- ^ Target</span><span>
</span><span id="line-154"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-comment">-- ^ One-shot substitution</span><span>
</span><span id="line-155"></span><span id="tcMatchTyKis"><span class="annot"><span class="annottext">tcMatchTyKis :: [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcMatchTyKis"><span class="hs-identifier hs-var hs-var">tcMatchTyKis</span></a></span></span><span> </span><span id="local-6989586621680854320"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854320"><span class="hs-identifier hs-var">tys1</span></a></span></span><span> </span><span id="local-6989586621680854319"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854319"><span class="hs-identifier hs-var">tys2</span></a></span></span><span>
</span><span id="line-156"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; BindFlag)
-&gt; Bool -&gt; [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tc_match_tys"><span class="hs-identifier hs-var">tc_match_tys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BindFlag -&gt; OutTyVar -&gt; BindFlag
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#BindMe"><span class="hs-identifier hs-var">BindMe</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854320"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854319"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-157"></span><span>
</span><span id="line-158"></span><span class="hs-comment">-- | Like 'tcMatchTys', but extending a substitution</span><span>
</span><span id="line-159"></span><span class="hs-comment">-- See also Note [tcMatchTy vs tcMatchTyKi]</span><span>
</span><span id="line-160"></span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTysX"><span class="hs-identifier hs-type">tcMatchTysX</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>       </span><span class="hs-comment">-- ^ Substitution to extend</span><span>
</span><span id="line-161"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>         </span><span class="hs-comment">-- ^ Template</span><span>
</span><span id="line-162"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>         </span><span class="hs-comment">-- ^ Target</span><span>
</span><span id="line-163"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-comment">-- ^ One-shot substitution</span><span>
</span><span id="line-164"></span><span id="tcMatchTysX"><span class="annot"><span class="annottext">tcMatchTysX :: TCvSubst -&gt; [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcMatchTysX"><span class="hs-identifier hs-var hs-var">tcMatchTysX</span></a></span></span><span> </span><span id="local-6989586621680854318"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854318"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854317"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854317"><span class="hs-identifier hs-var">tys1</span></a></span></span><span> </span><span id="local-6989586621680854316"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854316"><span class="hs-identifier hs-var">tys2</span></a></span></span><span>
</span><span id="line-165"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; BindFlag)
-&gt; Bool -&gt; TCvSubst -&gt; [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tc_match_tys_x"><span class="hs-identifier hs-var">tc_match_tys_x</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BindFlag -&gt; OutTyVar -&gt; BindFlag
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#BindMe"><span class="hs-identifier hs-var">BindMe</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854318"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854317"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854316"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-166"></span><span>
</span><span id="line-167"></span><span class="hs-comment">-- | Like 'tcMatchTyKis', but extending a substitution</span><span>
</span><span id="line-168"></span><span class="hs-comment">-- See also Note [tcMatchTy vs tcMatchTyKi]</span><span>
</span><span id="line-169"></span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTyKisX"><span class="hs-identifier hs-type">tcMatchTyKisX</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>        </span><span class="hs-comment">-- ^ Substitution to extend</span><span>
</span><span id="line-170"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>          </span><span class="hs-comment">-- ^ Template</span><span>
</span><span id="line-171"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>          </span><span class="hs-comment">-- ^ Target</span><span>
</span><span id="line-172"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>  </span><span class="hs-comment">-- ^ One-shot substitution</span><span>
</span><span id="line-173"></span><span id="tcMatchTyKisX"><span class="annot"><span class="annottext">tcMatchTyKisX :: TCvSubst -&gt; [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcMatchTyKisX"><span class="hs-identifier hs-var hs-var">tcMatchTyKisX</span></a></span></span><span> </span><span id="local-6989586621680854315"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854315"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854314"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854314"><span class="hs-identifier hs-var">tys1</span></a></span></span><span> </span><span id="local-6989586621680854313"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854313"><span class="hs-identifier hs-var">tys2</span></a></span></span><span>
</span><span id="line-174"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; BindFlag)
-&gt; Bool -&gt; TCvSubst -&gt; [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tc_match_tys_x"><span class="hs-identifier hs-var">tc_match_tys_x</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BindFlag -&gt; OutTyVar -&gt; BindFlag
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#BindMe"><span class="hs-identifier hs-var">BindMe</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854315"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854314"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854313"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-175"></span><span>
</span><span id="line-176"></span><span class="hs-comment">-- | Same as tc_match_tys_x, but starts with an empty substitution</span><span>
</span><span id="line-177"></span><span class="annot"><a href="GHC.Core.Unify.html#tc_match_tys"><span class="hs-identifier hs-type">tc_match_tys</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#BindFlag"><span class="hs-identifier hs-type">BindFlag</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-178"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>          </span><span class="hs-comment">-- ^ match kinds?</span><span>
</span><span id="line-179"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-180"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-181"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-182"></span><span id="tc_match_tys"><span class="annot"><span class="annottext">tc_match_tys :: (OutTyVar -&gt; BindFlag)
-&gt; Bool -&gt; [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tc_match_tys"><span class="hs-identifier hs-var hs-var">tc_match_tys</span></a></span></span><span> </span><span id="local-6989586621680854312"><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854312"><span class="hs-identifier hs-var">bind_me</span></a></span></span><span> </span><span id="local-6989586621680854311"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854311"><span class="hs-identifier hs-var">match_kis</span></a></span></span><span> </span><span id="local-6989586621680854310"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854310"><span class="hs-identifier hs-var">tys1</span></a></span></span><span> </span><span id="local-6989586621680854309"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854309"><span class="hs-identifier hs-var">tys2</span></a></span></span><span>
</span><span id="line-183"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; BindFlag)
-&gt; Bool -&gt; TCvSubst -&gt; [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tc_match_tys_x"><span class="hs-identifier hs-var">tc_match_tys_x</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854312"><span class="hs-identifier hs-var">bind_me</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854311"><span class="hs-identifier hs-var">match_kis</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkEmptyTCvSubst"><span class="hs-identifier hs-var">mkEmptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854307"><span class="hs-identifier hs-var">in_scope</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854310"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854309"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-184"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-185"></span><span>    </span><span id="local-6989586621680854307"><span class="annot"><span class="annottext">in_scope :: InScopeSet
</span><a href="#local-6989586621680854307"><span class="hs-identifier hs-var hs-var">in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypes"><span class="hs-identifier hs-var">tyCoVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854310"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypes"><span class="hs-identifier hs-var">tyCoVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854309"><span class="hs-identifier hs-var">tys2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-186"></span><span>
</span><span id="line-187"></span><span class="hs-comment">-- | Worker for 'tcMatchTysX' and 'tcMatchTyKisX'</span><span>
</span><span id="line-188"></span><span class="annot"><a href="GHC.Core.Unify.html#tc_match_tys_x"><span class="hs-identifier hs-type">tc_match_tys_x</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#BindFlag"><span class="hs-identifier hs-type">BindFlag</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-189"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>          </span><span class="hs-comment">-- ^ match kinds?</span><span>
</span><span id="line-190"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-191"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-192"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-193"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-194"></span><span id="tc_match_tys_x"><span class="annot"><span class="annottext">tc_match_tys_x :: (OutTyVar -&gt; BindFlag)
-&gt; Bool -&gt; TCvSubst -&gt; [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tc_match_tys_x"><span class="hs-identifier hs-var hs-var">tc_match_tys_x</span></a></span></span><span> </span><span id="local-6989586621680854303"><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854303"><span class="hs-identifier hs-var">bind_me</span></a></span></span><span> </span><span id="local-6989586621680854302"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854302"><span class="hs-identifier hs-var">match_kis</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span id="local-6989586621680854300"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854300"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680854299"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854299"><span class="hs-identifier hs-var">tv_env</span></a></span></span><span> </span><span id="local-6989586621680854298"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854298"><span class="hs-identifier hs-var">cv_env</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680854297"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854297"><span class="hs-identifier hs-var">tys1</span></a></span></span><span> </span><span id="local-6989586621680854296"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854296"><span class="hs-identifier hs-var">tys2</span></a></span></span><span>
</span><span id="line-195"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; BindFlag)
-&gt; Bool
-&gt; Bool
-&gt; Bool
-&gt; RnEnv2
-&gt; TvSubstEnv
-&gt; CvSubstEnv
-&gt; [Type]
-&gt; [Type]
-&gt; UnifyResultM (TvSubstEnv, CvSubstEnv)
</span><a href="GHC.Core.Unify.html#tc_unify_tys"><span class="hs-identifier hs-var">tc_unify_tys</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854303"><span class="hs-identifier hs-var">bind_me</span></a></span><span>
</span><span id="line-196"></span><span>                      </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>  </span><span class="hs-comment">-- Matching, not unifying</span><span>
</span><span id="line-197"></span><span>                      </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>  </span><span class="hs-comment">-- Not an injectivity check</span><span>
</span><span id="line-198"></span><span>                      </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854302"><span class="hs-identifier hs-var">match_kis</span></a></span><span>
</span><span id="line-199"></span><span>                      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; RnEnv2
</span><a href="GHC.Types.Var.Env.html#mkRnEnv2"><span class="hs-identifier hs-var">mkRnEnv2</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854300"><span class="hs-identifier hs-var">in_scope</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854299"><span class="hs-identifier hs-var">tv_env</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854298"><span class="hs-identifier hs-var">cv_env</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854297"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854296"><span class="hs-identifier hs-var">tys2</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-200"></span><span>      </span><span class="annot"><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-type">Unifiable</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680854292"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854292"><span class="hs-identifier hs-var">tv_env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680854291"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854291"><span class="hs-identifier hs-var">cv_env'</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-201"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Maybe TCvSubst
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(TCvSubst -&gt; Maybe TCvSubst) -&gt; TCvSubst -&gt; Maybe TCvSubst
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-var">TCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854300"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854292"><span class="hs-identifier hs-var">tv_env'</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854291"><span class="hs-identifier hs-var">cv_env'</span></a></span><span>
</span><span id="line-202"></span><span>      </span><span class="annot"><span class="annottext">UnifyResultM (TvSubstEnv, CvSubstEnv)
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe TCvSubst
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-203"></span><span>
</span><span id="line-204"></span><span class="hs-comment">-- | This one is called from the expression matcher,</span><span>
</span><span id="line-205"></span><span class="hs-comment">-- which already has a MatchEnv in hand</span><span>
</span><span id="line-206"></span><span class="annot"><a href="GHC.Core.Unify.html#ruleMatchTyKiX"><span class="hs-identifier hs-type">ruleMatchTyKiX</span></a></span><span>
</span><span id="line-207"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyCoVarSet"><span class="hs-identifier hs-type">TyCoVarSet</span></a></span><span>          </span><span class="hs-comment">-- ^ template variables</span><span>
</span><span id="line-208"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#RnEnv2"><span class="hs-identifier hs-type">RnEnv2</span></a></span><span>
</span><span id="line-209"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span>          </span><span class="hs-comment">-- ^ type substitution to extend</span><span>
</span><span id="line-210"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>                </span><span class="hs-comment">-- ^ Template</span><span>
</span><span id="line-211"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>                </span><span class="hs-comment">-- ^ Target</span><span>
</span><span id="line-212"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span>
</span><span id="line-213"></span><span id="ruleMatchTyKiX"><span class="annot"><span class="annottext">ruleMatchTyKiX :: VarSet -&gt; RnEnv2 -&gt; TvSubstEnv -&gt; Type -&gt; Type -&gt; Maybe TvSubstEnv
</span><a href="GHC.Core.Unify.html#ruleMatchTyKiX"><span class="hs-identifier hs-var hs-var">ruleMatchTyKiX</span></a></span></span><span> </span><span id="local-6989586621680854289"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680854289"><span class="hs-identifier hs-var">tmpl_tvs</span></a></span></span><span> </span><span id="local-6989586621680854288"><span class="annot"><span class="annottext">RnEnv2
</span><a href="#local-6989586621680854288"><span class="hs-identifier hs-var">rn_env</span></a></span></span><span> </span><span id="local-6989586621680854287"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854287"><span class="hs-identifier hs-var">tenv</span></a></span></span><span> </span><span id="local-6989586621680854286"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854286"><span class="hs-identifier hs-var">tmpl</span></a></span></span><span> </span><span id="local-6989586621680854285"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854285"><span class="hs-identifier hs-var">target</span></a></span></span><span>
</span><span id="line-214"></span><span class="hs-comment">-- See Note [Kind coercions in Unify]</span><span>
</span><span id="line-215"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; BindFlag)
-&gt; Bool
-&gt; Bool
-&gt; Bool
-&gt; RnEnv2
-&gt; TvSubstEnv
-&gt; CvSubstEnv
-&gt; [Type]
-&gt; [Type]
-&gt; UnifyResultM (TvSubstEnv, CvSubstEnv)
</span><a href="GHC.Core.Unify.html#tc_unify_tys"><span class="hs-identifier hs-var">tc_unify_tys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; OutTyVar -&gt; BindFlag
</span><a href="GHC.Core.Unify.html#matchBindFun"><span class="hs-identifier hs-var">matchBindFun</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680854289"><span class="hs-identifier hs-var">tmpl_tvs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-216"></span><span>                      </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-comment">-- &lt;-- this means to match the kinds</span><span>
</span><span id="line-217"></span><span>                      </span><span class="annot"><span class="annottext">RnEnv2
</span><a href="#local-6989586621680854288"><span class="hs-identifier hs-var">rn_env</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854287"><span class="hs-identifier hs-var">tenv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#emptyCvSubstEnv"><span class="hs-identifier hs-var">emptyCvSubstEnv</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854286"><span class="hs-identifier hs-var">tmpl</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854285"><span class="hs-identifier hs-var">target</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-218"></span><span>      </span><span class="annot"><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-type">Unifiable</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680854282"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854282"><span class="hs-identifier hs-var">tenv'</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; Maybe TvSubstEnv
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854282"><span class="hs-identifier hs-var">tenv'</span></a></span><span>
</span><span id="line-219"></span><span>      </span><span class="annot"><span class="annottext">UnifyResultM (TvSubstEnv, CvSubstEnv)
</span><span class="hs-identifier">_</span></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe TvSubstEnv
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-220"></span><span>
</span><span id="line-221"></span><span class="annot"><a href="GHC.Core.Unify.html#matchBindFun"><span class="hs-identifier hs-type">matchBindFun</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyCoVarSet"><span class="hs-identifier hs-type">TyCoVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#BindFlag"><span class="hs-identifier hs-type">BindFlag</span></a></span><span>
</span><span id="line-222"></span><span id="matchBindFun"><span class="annot"><span class="annottext">matchBindFun :: VarSet -&gt; OutTyVar -&gt; BindFlag
</span><a href="GHC.Core.Unify.html#matchBindFun"><span class="hs-identifier hs-var hs-var">matchBindFun</span></a></span></span><span> </span><span id="local-6989586621680854281"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680854281"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621680854280"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680854280"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680854280"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680854281"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#BindMe"><span class="hs-identifier hs-var">BindMe</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#Skolem"><span class="hs-identifier hs-var">Skolem</span></a></span><span>
</span><span id="line-223"></span><span>
</span><span id="line-224"></span><span>
</span><span id="line-225"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
                Rough matching
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-230"></span><span>
</span><span id="line-231"></span><span class="hs-comment">-- See Note [Rough match] field in GHC.Core.InstEnv</span><span>
</span><span id="line-232"></span><span>
</span><span id="line-233"></span><span class="annot"><a href="GHC.Core.Unify.html#roughMatchTcs"><span class="hs-identifier hs-type">roughMatchTcs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-234"></span><span id="roughMatchTcs"><span class="annot"><span class="annottext">roughMatchTcs :: [Type] -&gt; [Maybe Name]
</span><a href="GHC.Core.Unify.html#roughMatchTcs"><span class="hs-identifier hs-var hs-var">roughMatchTcs</span></a></span></span><span> </span><span id="local-6989586621680854277"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854277"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Maybe Name) -&gt; [Type] -&gt; [Maybe Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe Name
</span><a href="#local-6989586621680854276"><span class="hs-identifier hs-var">rough</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854277"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-235"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-236"></span><span>    </span><span id="local-6989586621680854276"><span class="annot"><span class="annottext">rough :: Type -&gt; Maybe Name
</span><a href="#local-6989586621680854276"><span class="hs-identifier hs-var hs-var">rough</span></a></span></span><span> </span><span id="local-6989586621680854274"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854274"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-237"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680854273"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854273"><span class="hs-identifier hs-var">ty'</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (Type, Coercion)
</span><a href="GHC.Core.Type.html#splitCastTy_maybe"><span class="hs-identifier hs-var">splitCastTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854274"><span class="hs-identifier hs-var">ty</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe Name
</span><a href="#local-6989586621680854276"><span class="hs-identifier hs-var">rough</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854273"><span class="hs-identifier hs-var">ty'</span></a></span><span>
</span><span id="line-238"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680854271"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854271"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (TyCon, [Type])
Type -&gt; Maybe (TyCon, [Type])
</span><a href="GHC.Core.Type.html#splitTyConApp_maybe"><span class="hs-identifier hs-var">splitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854274"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Maybe Name
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Name
</span><a href="GHC.Core.TyCon.html#tyConName"><span class="hs-identifier hs-var hs-var">tyConName</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854271"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-239"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Name
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-240"></span><span>
</span><span id="line-241"></span><span class="annot"><a href="GHC.Core.Unify.html#instanceCantMatch"><span class="hs-identifier hs-type">instanceCantMatch</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-242"></span><span class="hs-comment">-- (instanceCantMatch tcs1 tcs2) returns True if tcs1 cannot</span><span>
</span><span id="line-243"></span><span class="hs-comment">-- possibly be instantiated to actual, nor vice versa;</span><span>
</span><span id="line-244"></span><span class="hs-comment">-- False is non-committal</span><span>
</span><span id="line-245"></span><span id="instanceCantMatch"><span class="annot"><span class="annottext">instanceCantMatch :: [Maybe Name] -&gt; [Maybe Name] -&gt; Bool
</span><a href="GHC.Core.Unify.html#instanceCantMatch"><span class="hs-identifier hs-var hs-var">instanceCantMatch</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680854268"><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621680854268"><span class="hs-identifier hs-var">mt</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680854267"><span class="annot"><span class="annottext">[Maybe Name]
</span><a href="#local-6989586621680854267"><span class="hs-identifier hs-var">ts</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680854266"><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621680854266"><span class="hs-identifier hs-var">ma</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680854265"><span class="annot"><span class="annottext">[Maybe Name]
</span><a href="#local-6989586621680854265"><span class="hs-keyword hs-var">as</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Name -&gt; Maybe Name -&gt; Bool
</span><a href="GHC.Core.Unify.html#itemCantMatch"><span class="hs-identifier hs-var">itemCantMatch</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621680854268"><span class="hs-identifier hs-var">mt</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621680854266"><span class="hs-identifier hs-var">ma</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">[Maybe Name] -&gt; [Maybe Name] -&gt; Bool
</span><a href="GHC.Core.Unify.html#instanceCantMatch"><span class="hs-identifier hs-var">instanceCantMatch</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe Name]
</span><a href="#local-6989586621680854267"><span class="hs-identifier hs-var">ts</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe Name]
</span><a href="#local-6989586621680854265"><span class="hs-keyword hs-var">as</span></a></span><span>
</span><span id="line-246"></span><span class="annot"><a href="GHC.Core.Unify.html#instanceCantMatch"><span class="hs-identifier hs-var">instanceCantMatch</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe Name]
</span><span class="hs-identifier">_</span></span><span>         </span><span class="annot"><span class="annottext">[Maybe Name]
</span><span class="hs-identifier">_</span></span><span>         </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>  </span><span class="hs-comment">-- Safe</span><span>
</span><span id="line-247"></span><span>
</span><span id="line-248"></span><span class="annot"><a href="GHC.Core.Unify.html#itemCantMatch"><span class="hs-identifier hs-type">itemCantMatch</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-249"></span><span id="itemCantMatch"><span class="annot"><span class="annottext">itemCantMatch :: Maybe Name -&gt; Maybe Name -&gt; Bool
</span><a href="GHC.Core.Unify.html#itemCantMatch"><span class="hs-identifier hs-var hs-var">itemCantMatch</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680854262"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621680854262"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680854261"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621680854261"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621680854262"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Name -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621680854261"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-250"></span><span class="annot"><a href="GHC.Core.Unify.html#itemCantMatch"><span class="hs-identifier hs-var">itemCantMatch</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><span class="hs-identifier">_</span></span><span>        </span><span class="annot"><span class="annottext">Maybe Name
</span><span class="hs-identifier">_</span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-251"></span><span>
</span><span id="line-252"></span><span>
</span><span id="line-253"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                GADTs
*                                                                      *
************************************************************************

Note [Pruning dead case alternatives]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider        data T a where
                   T1 :: T Int
                   T2 :: T a

                newtype X = MkX Int
                newtype Y = MkY Char

                type family F a
                type instance F Bool = Int

Now consider    case x of { T1 -&gt; e1; T2 -&gt; e2 }

The question before the house is this: if I know something about the type
of x, can I prune away the T1 alternative?

Suppose x::T Char.  It's impossible to construct a (T Char) using T1,
        Answer = YES we can prune the T1 branch (clearly)

Suppose x::T (F a), where 'a' is in scope.  Then 'a' might be instantiated
to 'Bool', in which case x::T Int, so
        ANSWER = NO (clearly)

We see here that we want precisely the apartness check implemented within
tcUnifyTysFG. So that's what we do! Two types cannot match if they are surely
apart. Note that since we are simply dropping dead code, a conservative test
suffices.
-}</span><span>
</span><span id="line-289"></span><span>
</span><span id="line-290"></span><span class="hs-comment">-- | Given a list of pairs of types, are any two members of a pair surely</span><span>
</span><span id="line-291"></span><span class="hs-comment">-- apart, even after arbitrary type function evaluation and substitution?</span><span>
</span><span id="line-292"></span><span class="annot"><a href="GHC.Core.Unify.html#typesCantMatch"><span class="hs-identifier hs-type">typesCantMatch</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-293"></span><span class="hs-comment">-- See Note [Pruning dead case alternatives]</span><span>
</span><span id="line-294"></span><span id="typesCantMatch"><span class="annot"><span class="annottext">typesCantMatch :: [(Type, Type)] -&gt; Bool
</span><a href="GHC.Core.Unify.html#typesCantMatch"><span class="hs-identifier hs-var hs-var">typesCantMatch</span></a></span></span><span> </span><span id="local-6989586621680854259"><span class="annot"><span class="annottext">[(Type, Type)]
</span><a href="#local-6989586621680854259"><span class="hs-identifier hs-var">prs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Type, Type) -&gt; Bool) -&gt; [(Type, Type)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Type -&gt; Type -&gt; Bool) -&gt; (Type, Type) -&gt; Bool
forall a b c. (a -&gt; b -&gt; c) -&gt; (a, b) -&gt; c
</span><a href="../../base/src/Data.Tuple.html#uncurry"><span class="hs-identifier hs-var">uncurry</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Bool
</span><a href="#local-6989586621680854256"><span class="hs-identifier hs-var">cant_match</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Type, Type)]
</span><a href="#local-6989586621680854259"><span class="hs-identifier hs-var">prs</span></a></span><span>
</span><span id="line-295"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-296"></span><span>    </span><span class="annot"><a href="#local-6989586621680854256"><span class="hs-identifier hs-type">cant_match</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-297"></span><span>    </span><span id="local-6989586621680854256"><span class="annot"><span class="annottext">cant_match :: Type -&gt; Type -&gt; Bool
</span><a href="#local-6989586621680854256"><span class="hs-identifier hs-var hs-var">cant_match</span></a></span></span><span> </span><span id="local-6989586621680854255"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854255"><span class="hs-identifier hs-var">t1</span></a></span></span><span> </span><span id="local-6989586621680854254"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854254"><span class="hs-identifier hs-var">t2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; BindFlag) -&gt; [Type] -&gt; [Type] -&gt; UnifyResult
</span><a href="GHC.Core.Unify.html#tcUnifyTysFG"><span class="hs-identifier hs-var">tcUnifyTysFG</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BindFlag -&gt; OutTyVar -&gt; BindFlag
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#BindMe"><span class="hs-identifier hs-var">BindMe</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854255"><span class="hs-identifier hs-var">t1</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854254"><span class="hs-identifier hs-var">t2</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-298"></span><span>      </span><span class="annot"><span class="annottext">UnifyResult
</span><a href="GHC.Core.Unify.html#SurelyApart"><span class="hs-identifier hs-var">SurelyApart</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-299"></span><span>      </span><span class="annot"><span class="annottext">UnifyResult
</span><span class="hs-identifier">_</span></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-300"></span><span>
</span><span id="line-301"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
             Unification
*                                                                      *
************************************************************************

Note [Fine-grained unification]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Do the types (x, x) and ([y], y) unify? The answer is seemingly &quot;no&quot; --
no substitution to finite types makes these match. But, a substitution to
*infinite* types can unify these two types: [x |-&gt; [[[...]]], y |-&gt; [[[...]]] ].
Why do we care? Consider these two type family instances:

type instance F x x   = Int
type instance F [y] y = Bool

If we also have

type instance Looper = [Looper]

then the instances potentially overlap. The solution is to use unification
over infinite terms. This is possible (see [1] for lots of gory details), but
a full algorithm is a little more power than we need. Instead, we make a
conservative approximation and just omit the occurs check.

[1]: http://research.microsoft.com/en-us/um/people/simonpj/papers/ext-f/axioms-extended.pdf

tcUnifyTys considers an occurs-check problem as the same as general unification
failure.

tcUnifyTysFG (&quot;fine-grained&quot;) returns one of three results: success, occurs-check
failure (&quot;MaybeApart&quot;), or general failure (&quot;SurelyApart&quot;).

See also #8162.

It's worth noting that unification in the presence of infinite types is not
complete. This means that, sometimes, a closed type family does not reduce
when it should. See test case indexed-types/should_fail/Overlap15 for an
example.

Note [The substitution in MaybeApart]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The constructor MaybeApart carries data with it, typically a TvSubstEnv. Why?
Because consider unifying these:

(a, a, Int) ~ (b, [b], Bool)

If we go left-to-right, we start with [a |-&gt; b]. Then, on the middle terms, we
apply the subst we have so far and discover that we need [b |-&gt; [b]]. Because
this fails the occurs check, we say that the types are MaybeApart (see above
Note [Fine-grained unification]). But, we can't stop there! Because if we
continue, we discover that Int is SurelyApart from Bool, and therefore the
types are apart. This has practical consequences for the ability for closed
type family applications to reduce. See test case
indexed-types/should_compile/Overlap14.

Note [Unification with skolems]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If we discover that two types unify if and only if a skolem variable is
substituted, we can't properly unify the types. But, that skolem variable
may later be instantiated with a unifyable type. So, we return maybeApart
in these cases.
-}</span><span>
</span><span id="line-365"></span><span>
</span><span id="line-366"></span><span class="hs-comment">-- | Simple unification of two types; all type variables are bindable</span><span>
</span><span id="line-367"></span><span class="hs-comment">-- Precondition: the kinds are already equal</span><span>
</span><span id="line-368"></span><span class="annot"><a href="GHC.Core.Unify.html#tcUnifyTy"><span class="hs-identifier hs-type">tcUnifyTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>       </span><span class="hs-comment">-- All tyvars are bindable</span><span>
</span><span id="line-369"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-370"></span><span>                       </span><span class="hs-comment">-- A regular one-shot (idempotent) substitution</span><span>
</span><span id="line-371"></span><span id="tcUnifyTy"><span class="annot"><span class="annottext">tcUnifyTy :: Type -&gt; Type -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcUnifyTy"><span class="hs-identifier hs-var hs-var">tcUnifyTy</span></a></span></span><span> </span><span id="local-6989586621680854252"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854252"><span class="hs-identifier hs-var">t1</span></a></span></span><span> </span><span id="local-6989586621680854251"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854251"><span class="hs-identifier hs-var">t2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; BindFlag) -&gt; [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcUnifyTys"><span class="hs-identifier hs-var">tcUnifyTys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BindFlag -&gt; OutTyVar -&gt; BindFlag
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#BindMe"><span class="hs-identifier hs-var">BindMe</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854252"><span class="hs-identifier hs-var">t1</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854251"><span class="hs-identifier hs-var">t2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-372"></span><span>
</span><span id="line-373"></span><span class="hs-comment">-- | Like 'tcUnifyTy', but also unifies the kinds</span><span>
</span><span id="line-374"></span><span class="annot"><a href="GHC.Core.Unify.html#tcUnifyTyKi"><span class="hs-identifier hs-type">tcUnifyTyKi</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-375"></span><span id="tcUnifyTyKi"><span class="annot"><span class="annottext">tcUnifyTyKi :: Type -&gt; Type -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcUnifyTyKi"><span class="hs-identifier hs-var hs-var">tcUnifyTyKi</span></a></span></span><span> </span><span id="local-6989586621680854250"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854250"><span class="hs-identifier hs-var">t1</span></a></span></span><span> </span><span id="local-6989586621680854249"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854249"><span class="hs-identifier hs-var">t2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; BindFlag) -&gt; [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcUnifyTyKis"><span class="hs-identifier hs-var">tcUnifyTyKis</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BindFlag -&gt; OutTyVar -&gt; BindFlag
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#BindMe"><span class="hs-identifier hs-var">BindMe</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854250"><span class="hs-identifier hs-var">t1</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854249"><span class="hs-identifier hs-var">t2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-376"></span><span>
</span><span id="line-377"></span><span class="hs-comment">-- | Unify two types, treating type family applications as possibly unifying</span><span>
</span><span id="line-378"></span><span class="hs-comment">-- with anything and looking through injective type family applications.</span><span>
</span><span id="line-379"></span><span class="hs-comment">-- Precondition: kinds are the same</span><span>
</span><span id="line-380"></span><span class="annot"><a href="GHC.Core.Unify.html#tcUnifyTyWithTFs"><span class="hs-identifier hs-type">tcUnifyTyWithTFs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>  </span><span class="hs-comment">-- ^ True &lt;=&gt; do two-way unification;</span><span>
</span><span id="line-381"></span><span>                          </span><span class="hs-comment">--   False &lt;=&gt; do one-way matching.</span><span>
</span><span id="line-382"></span><span>                          </span><span class="hs-comment">--   See end of sec 5.2 from the paper</span><span>
</span><span id="line-383"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-384"></span><span class="hs-comment">-- This algorithm is an implementation of the &quot;Algorithm U&quot; presented in</span><span>
</span><span id="line-385"></span><span class="hs-comment">-- the paper &quot;Injective type families for Haskell&quot;, Figures 2 and 3.</span><span>
</span><span id="line-386"></span><span class="hs-comment">-- The code is incorporated with the standard unifier for convenience, but</span><span>
</span><span id="line-387"></span><span class="hs-comment">-- its operation should match the specification in the paper.</span><span>
</span><span id="line-388"></span><span id="tcUnifyTyWithTFs"><span class="annot"><span class="annottext">tcUnifyTyWithTFs :: Bool -&gt; Type -&gt; Type -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcUnifyTyWithTFs"><span class="hs-identifier hs-var hs-var">tcUnifyTyWithTFs</span></a></span></span><span> </span><span id="local-6989586621680854248"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854248"><span class="hs-identifier hs-var">twoWay</span></a></span></span><span> </span><span id="local-6989586621680854247"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854247"><span class="hs-identifier hs-var">t1</span></a></span></span><span> </span><span id="local-6989586621680854246"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854246"><span class="hs-identifier hs-var">t2</span></a></span></span><span>
</span><span id="line-389"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; BindFlag)
-&gt; Bool
-&gt; Bool
-&gt; Bool
-&gt; RnEnv2
-&gt; TvSubstEnv
-&gt; CvSubstEnv
-&gt; [Type]
-&gt; [Type]
-&gt; UnifyResultM (TvSubstEnv, CvSubstEnv)
</span><a href="GHC.Core.Unify.html#tc_unify_tys"><span class="hs-identifier hs-var">tc_unify_tys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BindFlag -&gt; OutTyVar -&gt; BindFlag
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#BindMe"><span class="hs-identifier hs-var">BindMe</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854248"><span class="hs-identifier hs-var">twoWay</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-390"></span><span>                       </span><span class="annot"><span class="annottext">RnEnv2
</span><a href="#local-6989586621680854245"><span class="hs-identifier hs-var">rn_env</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#emptyTvSubstEnv"><span class="hs-identifier hs-var">emptyTvSubstEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#emptyCvSubstEnv"><span class="hs-identifier hs-var">emptyCvSubstEnv</span></a></span><span>
</span><span id="line-391"></span><span>                       </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854247"><span class="hs-identifier hs-var">t1</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854246"><span class="hs-identifier hs-var">t2</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-392"></span><span>      </span><span class="annot"><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-type">Unifiable</span></a></span><span>  </span><span class="hs-special">(</span><span id="local-6989586621680854243"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854243"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Maybe TCvSubst
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(TCvSubst -&gt; Maybe TCvSubst) -&gt; TCvSubst -&gt; Maybe TCvSubst
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TCvSubst
</span><a href="#local-6989586621680854242"><span class="hs-identifier hs-var">maybe_fix</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854243"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-393"></span><span>      </span><span class="annot"><a href="GHC.Core.Unify.html#MaybeApart"><span class="hs-identifier hs-type">MaybeApart</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680854240"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854240"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Maybe TCvSubst
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(TCvSubst -&gt; Maybe TCvSubst) -&gt; TCvSubst -&gt; Maybe TCvSubst
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TCvSubst
</span><a href="#local-6989586621680854242"><span class="hs-identifier hs-var">maybe_fix</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854240"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-394"></span><span>      </span><span class="hs-comment">-- we want to *succeed* in questionable cases. This is a</span><span>
</span><span id="line-395"></span><span>      </span><span class="hs-comment">-- pre-unification algorithm.</span><span>
</span><span id="line-396"></span><span>      </span><span class="annot"><span class="annottext">UnifyResultM (TvSubstEnv, CvSubstEnv)
</span><a href="GHC.Core.Unify.html#SurelyApart"><span class="hs-identifier hs-var">SurelyApart</span></a></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe TCvSubst
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-397"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-398"></span><span>    </span><span id="local-6989586621680854239"><span class="annot"><span class="annottext">in_scope :: InScopeSet
</span><a href="#local-6989586621680854239"><span class="hs-identifier hs-var hs-var">in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; InScopeSet) -&gt; VarSet -&gt; InScopeSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypes"><span class="hs-identifier hs-var">tyCoVarsOfTypes</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854247"><span class="hs-identifier hs-var">t1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854246"><span class="hs-identifier hs-var">t2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-399"></span><span>    </span><span id="local-6989586621680854245"><span class="annot"><span class="annottext">rn_env :: RnEnv2
</span><a href="#local-6989586621680854245"><span class="hs-identifier hs-var hs-var">rn_env</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; RnEnv2
</span><a href="GHC.Types.Var.Env.html#mkRnEnv2"><span class="hs-identifier hs-var">mkRnEnv2</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854239"><span class="hs-identifier hs-var">in_scope</span></a></span><span>
</span><span id="line-400"></span><span>
</span><span id="line-401"></span><span>    </span><span id="local-6989586621680854242"><span class="annot"><span class="annottext">maybe_fix :: TvSubstEnv -&gt; TCvSubst
</span><a href="#local-6989586621680854242"><span class="hs-identifier hs-var hs-var">maybe_fix</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854248"><span class="hs-identifier hs-var">twoWay</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.Unify.html#niFixTCvSubst"><span class="hs-identifier hs-var">niFixTCvSubst</span></a></span><span>
</span><span id="line-402"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkTvSubst"><span class="hs-identifier hs-var">mkTvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854239"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="hs-comment">-- when matching, don't confuse</span><span>
</span><span id="line-403"></span><span>                                               </span><span class="hs-comment">-- domain with range</span><span>
</span><span id="line-404"></span><span>
</span><span id="line-405"></span><span class="hs-comment">-----------------</span><span>
</span><span id="line-406"></span><span class="annot"><a href="GHC.Core.Unify.html#tcUnifyTys"><span class="hs-identifier hs-type">tcUnifyTys</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#BindFlag"><span class="hs-identifier hs-type">BindFlag</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-407"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-408"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-409"></span><span>                                </span><span class="hs-comment">-- ^ A regular one-shot (idempotent) substitution</span><span>
</span><span id="line-410"></span><span>                                </span><span class="hs-comment">-- that unifies the erased types. See comments</span><span>
</span><span id="line-411"></span><span>                                </span><span class="hs-comment">-- for 'tcUnifyTysFG'</span><span>
</span><span id="line-412"></span><span>
</span><span id="line-413"></span><span class="hs-comment">-- The two types may have common type variables, and indeed do so in the</span><span>
</span><span id="line-414"></span><span class="hs-comment">-- second call to tcUnifyTys in GHC.Tc.Instance.FunDeps.checkClsFD</span><span>
</span><span id="line-415"></span><span id="tcUnifyTys"><span class="annot"><span class="annottext">tcUnifyTys :: (OutTyVar -&gt; BindFlag) -&gt; [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcUnifyTys"><span class="hs-identifier hs-var hs-var">tcUnifyTys</span></a></span></span><span> </span><span id="local-6989586621680854236"><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854236"><span class="hs-identifier hs-var">bind_fn</span></a></span></span><span> </span><span id="local-6989586621680854235"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854235"><span class="hs-identifier hs-var">tys1</span></a></span></span><span> </span><span id="local-6989586621680854234"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854234"><span class="hs-identifier hs-var">tys2</span></a></span></span><span>
</span><span id="line-416"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; BindFlag) -&gt; [Type] -&gt; [Type] -&gt; UnifyResult
</span><a href="GHC.Core.Unify.html#tcUnifyTysFG"><span class="hs-identifier hs-var">tcUnifyTysFG</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854236"><span class="hs-identifier hs-var">bind_fn</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854235"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854234"><span class="hs-identifier hs-var">tys2</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-417"></span><span>      </span><span class="annot"><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-type">Unifiable</span></a></span><span> </span><span id="local-6989586621680854233"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854233"><span class="hs-identifier hs-var">result</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Maybe TCvSubst
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854233"><span class="hs-identifier hs-var">result</span></a></span><span>
</span><span id="line-418"></span><span>      </span><span class="annot"><span class="annottext">UnifyResult
</span><span class="hs-identifier">_</span></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe TCvSubst
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-419"></span><span>
</span><span id="line-420"></span><span class="hs-comment">-- | Like 'tcUnifyTys' but also unifies the kinds</span><span>
</span><span id="line-421"></span><span class="annot"><a href="GHC.Core.Unify.html#tcUnifyTyKis"><span class="hs-identifier hs-type">tcUnifyTyKis</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#BindFlag"><span class="hs-identifier hs-type">BindFlag</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-422"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-423"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-424"></span><span id="tcUnifyTyKis"><span class="annot"><span class="annottext">tcUnifyTyKis :: (OutTyVar -&gt; BindFlag) -&gt; [Type] -&gt; [Type] -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcUnifyTyKis"><span class="hs-identifier hs-var hs-var">tcUnifyTyKis</span></a></span></span><span> </span><span id="local-6989586621680854232"><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854232"><span class="hs-identifier hs-var">bind_fn</span></a></span></span><span> </span><span id="local-6989586621680854231"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854231"><span class="hs-identifier hs-var">tys1</span></a></span></span><span> </span><span id="local-6989586621680854230"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854230"><span class="hs-identifier hs-var">tys2</span></a></span></span><span>
</span><span id="line-425"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; BindFlag) -&gt; [Type] -&gt; [Type] -&gt; UnifyResult
</span><a href="GHC.Core.Unify.html#tcUnifyTyKisFG"><span class="hs-identifier hs-var">tcUnifyTyKisFG</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854232"><span class="hs-identifier hs-var">bind_fn</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854231"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854230"><span class="hs-identifier hs-var">tys2</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-426"></span><span>      </span><span class="annot"><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-type">Unifiable</span></a></span><span> </span><span id="local-6989586621680854228"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854228"><span class="hs-identifier hs-var">result</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Maybe TCvSubst
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854228"><span class="hs-identifier hs-var">result</span></a></span><span>
</span><span id="line-427"></span><span>      </span><span class="annot"><span class="annottext">UnifyResult
</span><span class="hs-identifier">_</span></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe TCvSubst
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-428"></span><span>
</span><span id="line-429"></span><span class="hs-comment">-- This type does double-duty. It is used in the UM (unifier monad) and to</span><span>
</span><span id="line-430"></span><span class="hs-comment">-- return the final result. See Note [Fine-grained unification]</span><span>
</span><span id="line-431"></span><span class="hs-keyword">type</span><span> </span><span id="UnifyResult"><span class="annot"><a href="GHC.Core.Unify.html#UnifyResult"><span class="hs-identifier hs-var">UnifyResult</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UnifyResultM"><span class="hs-identifier hs-type">UnifyResultM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-432"></span><span class="hs-keyword">data</span><span> </span><span id="UnifyResultM"><span class="annot"><a href="GHC.Core.Unify.html#UnifyResultM"><span class="hs-identifier hs-var">UnifyResultM</span></a></span></span><span> </span><span id="local-6989586621680854549"><span class="annot"><a href="#local-6989586621680854549"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="Unifiable"><span class="annot"><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-var">Unifiable</span></a></span></span><span> </span><span class="annot"><a href="#local-6989586621680854549"><span class="hs-identifier hs-type">a</span></a></span><span>        </span><span class="hs-comment">-- the subst that unifies the types</span><span>
</span><span id="line-433"></span><span>                    </span><span class="hs-glyph">|</span><span> </span><span id="MaybeApart"><span class="annot"><a href="GHC.Core.Unify.html#MaybeApart"><span class="hs-identifier hs-var">MaybeApart</span></a></span></span><span> </span><span class="annot"><a href="#local-6989586621680854549"><span class="hs-identifier hs-type">a</span></a></span><span>       </span><span class="hs-comment">-- the subst has as much as we know</span><span>
</span><span id="line-434"></span><span>                                         </span><span class="hs-comment">-- it must be part of a most general unifier</span><span>
</span><span id="line-435"></span><span>                                         </span><span class="hs-comment">-- See Note [The substitution in MaybeApart]</span><span>
</span><span id="line-436"></span><span>                    </span><span class="hs-glyph">|</span><span> </span><span id="SurelyApart"><span class="annot"><a href="GHC.Core.Unify.html#SurelyApart"><span class="hs-identifier hs-var">SurelyApart</span></a></span></span><span>
</span><span id="line-437"></span><span>                    </span><span class="hs-keyword">deriving</span><span> </span><span id="local-6989586621680854224"><span id="local-6989586621680854226"><span class="annot"><span class="annottext">(forall a b. (a -&gt; b) -&gt; UnifyResultM a -&gt; UnifyResultM b)
-&gt; (forall a b. a -&gt; UnifyResultM b -&gt; UnifyResultM a)
-&gt; Functor UnifyResultM
forall a b. a -&gt; UnifyResultM b -&gt; UnifyResultM a
forall a b. (a -&gt; b) -&gt; UnifyResultM a -&gt; UnifyResultM b
forall (f :: * -&gt; *).
(forall a b. (a -&gt; b) -&gt; f a -&gt; f b)
-&gt; (forall a b. a -&gt; f b -&gt; f a) -&gt; Functor f
&lt;$ :: forall a b. a -&gt; UnifyResultM b -&gt; UnifyResultM a
$c&lt;$ :: forall a b. a -&gt; UnifyResultM b -&gt; UnifyResultM a
fmap :: forall a b. (a -&gt; b) -&gt; UnifyResultM a -&gt; UnifyResultM b
$cfmap :: forall a b. (a -&gt; b) -&gt; UnifyResultM a -&gt; UnifyResultM b
</span><a href="../../base/src/GHC.Base.html#Functor"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Functor</span></a></span></span></span><span>
</span><span id="line-438"></span><span>
</span><span id="line-439"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680854212"><span id="local-6989586621680854214"><span id="local-6989586621680854216"><span class="annot"><a href="../../base/src/GHC.Base.html#Applicative"><span class="hs-identifier hs-type">Applicative</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UnifyResultM"><span class="hs-identifier hs-type">UnifyResultM</span></a></span></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-440"></span><span>  </span><span id="local-6989586621680854210"><span class="annot"><span class="annottext">pure :: forall a. a -&gt; UnifyResultM a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var hs-var hs-var hs-var">pure</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; UnifyResultM a
forall a. a -&gt; UnifyResultM a
</span><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-var">Unifiable</span></a></span><span>
</span><span id="line-441"></span><span>  </span><span id="local-6989586621680854208"><span class="annot"><span class="annottext">&lt;*&gt; :: forall a b.
UnifyResultM (a -&gt; b) -&gt; UnifyResultM a -&gt; UnifyResultM b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">(&lt;*&gt;)</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnifyResultM (a -&gt; b) -&gt; UnifyResultM a -&gt; UnifyResultM b
forall (m :: * -&gt; *) a b. Monad m =&gt; m (a -&gt; b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#ap"><span class="hs-identifier hs-var">ap</span></a></span><span>
</span><span id="line-442"></span><span>
</span><span id="line-443"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680854200"><span id="local-6989586621680854202"><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UnifyResultM"><span class="hs-identifier hs-type">UnifyResultM</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-444"></span><span>
</span><span id="line-445"></span><span>  </span><span class="annot"><span class="annottext">UnifyResultM a
</span><a href="GHC.Core.Unify.html#SurelyApart"><span class="hs-identifier hs-var">SurelyApart</span></a></span><span>  </span><span id="local-6989586621680854198"><span class="annot"><span class="annottext">&gt;&gt;= :: forall a b.
UnifyResultM a -&gt; (a -&gt; UnifyResultM b) -&gt; UnifyResultM b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var hs-var hs-var hs-var">&gt;&gt;=</span></a></span></span><span> </span><span class="annot"><span class="annottext">a -&gt; UnifyResultM b
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnifyResultM b
forall a. UnifyResultM a
</span><a href="GHC.Core.Unify.html#SurelyApart"><span class="hs-identifier hs-var">SurelyApart</span></a></span><span>
</span><span id="line-446"></span><span>  </span><span class="annot"><a href="GHC.Core.Unify.html#MaybeApart"><span class="hs-identifier hs-type">MaybeApart</span></a></span><span> </span><span id="local-6989586621680854197"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680854197"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span id="local-6989586621680854196"><span class="annot"><span class="annottext">a -&gt; UnifyResultM b
</span><a href="#local-6989586621680854196"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">a -&gt; UnifyResultM b
</span><a href="#local-6989586621680854196"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680854197"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-447"></span><span>                         </span><span class="annot"><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-type">Unifiable</span></a></span><span> </span><span id="local-6989586621680854195"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621680854195"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">b -&gt; UnifyResultM b
forall a. a -&gt; UnifyResultM a
</span><a href="GHC.Core.Unify.html#MaybeApart"><span class="hs-identifier hs-var">MaybeApart</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621680854195"><span class="hs-identifier hs-var">y</span></a></span><span>
</span><span id="line-448"></span><span>                         </span><span id="local-6989586621680854194"><span class="annot"><span class="annottext">UnifyResultM b
</span><a href="#local-6989586621680854194"><span class="hs-identifier hs-var">other</span></a></span></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UnifyResultM b
</span><a href="#local-6989586621680854194"><span class="hs-identifier hs-var">other</span></a></span><span>
</span><span id="line-449"></span><span>  </span><span class="annot"><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-type">Unifiable</span></a></span><span> </span><span id="local-6989586621680854193"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680854193"><span class="hs-identifier hs-var">x</span></a></span></span><span>  </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span id="local-6989586621680854192"><span class="annot"><span class="annottext">a -&gt; UnifyResultM b
</span><a href="#local-6989586621680854192"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; UnifyResultM b
</span><a href="#local-6989586621680854192"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680854193"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-450"></span><span>
</span><span id="line-451"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680854184"><span id="local-6989586621680854186"><span class="annot"><a href="../../base/src/GHC.Base.html#Alternative"><span class="hs-identifier hs-type">Alternative</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UnifyResultM"><span class="hs-identifier hs-type">UnifyResultM</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-452"></span><span>  </span><span id="local-6989586621680854182"><span class="annot"><span class="annottext">empty :: forall a. UnifyResultM a
</span><a href="#local-6989586621680854182"><span class="hs-identifier hs-var hs-var hs-var hs-var">empty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnifyResultM a
forall a. UnifyResultM a
</span><a href="GHC.Core.Unify.html#SurelyApart"><span class="hs-identifier hs-var">SurelyApart</span></a></span><span>
</span><span id="line-453"></span><span>
</span><span id="line-454"></span><span>  </span><span id="local-6989586621680854181"><span class="annot"><span class="annottext">a :: UnifyResultM a
</span><a href="#local-6989586621680854181"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-type">Unifiable</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>  </span><span id="local-6989586621680854180"><span class="annot"><span class="annottext">&lt;|&gt; :: forall a. UnifyResultM a -&gt; UnifyResultM a -&gt; UnifyResultM a
</span><a href="../../base/src/GHC.Base.html#%3C%7C%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">&lt;|&gt;</span></a></span></span><span> </span><span class="annot"><span class="annottext">UnifyResultM a
</span><span class="hs-identifier">_</span></span><span>                 </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnifyResultM a
</span><a href="#local-6989586621680854181"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-455"></span><span>  </span><span class="annot"><span class="annottext">UnifyResultM a
</span><span class="hs-identifier">_</span></span><span>                 </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3C%7C%3E"><span class="hs-operator hs-var">&lt;|&gt;</span></a></span><span> </span><span id="local-6989586621680854178"><span class="annot"><span class="annottext">b :: UnifyResultM a
</span><a href="#local-6989586621680854178"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-type">Unifiable</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnifyResultM a
</span><a href="#local-6989586621680854178"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-456"></span><span>  </span><span id="local-6989586621680854177"><span class="annot"><span class="annottext">a :: UnifyResultM a
</span><a href="#local-6989586621680854177"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Unify.html#MaybeApart"><span class="hs-identifier hs-type">MaybeApart</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3C%7C%3E"><span class="hs-operator hs-var">&lt;|&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">UnifyResultM a
</span><span class="hs-identifier">_</span></span><span>                 </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnifyResultM a
</span><a href="#local-6989586621680854177"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-457"></span><span>  </span><span class="annot"><span class="annottext">UnifyResultM a
</span><span class="hs-identifier">_</span></span><span>                 </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3C%7C%3E"><span class="hs-operator hs-var">&lt;|&gt;</span></a></span><span> </span><span id="local-6989586621680854176"><span class="annot"><span class="annottext">b :: UnifyResultM a
</span><a href="#local-6989586621680854176"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Unify.html#MaybeApart"><span class="hs-identifier hs-type">MaybeApart</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnifyResultM a
</span><a href="#local-6989586621680854176"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-458"></span><span>  </span><span class="annot"><span class="annottext">UnifyResultM a
</span><a href="GHC.Core.Unify.html#SurelyApart"><span class="hs-identifier hs-var">SurelyApart</span></a></span><span>       </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3C%7C%3E"><span class="hs-operator hs-var">&lt;|&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">UnifyResultM a
</span><a href="GHC.Core.Unify.html#SurelyApart"><span class="hs-identifier hs-var">SurelyApart</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnifyResultM a
forall a. UnifyResultM a
</span><a href="GHC.Core.Unify.html#SurelyApart"><span class="hs-identifier hs-var">SurelyApart</span></a></span><span>
</span><span id="line-459"></span><span>
</span><span id="line-460"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680854168"><span id="local-6989586621680854170"><span class="annot"><a href="../../base/src/GHC.Base.html#MonadPlus"><span class="hs-identifier hs-type">MonadPlus</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UnifyResultM"><span class="hs-identifier hs-type">UnifyResultM</span></a></span></span></span><span>
</span><span id="line-461"></span><span>
</span><span id="line-462"></span><span class="hs-comment">-- | @tcUnifyTysFG bind_tv tys1 tys2@ attepts to find a substitution @s@ (whose</span><span>
</span><span id="line-463"></span><span class="hs-comment">-- domain elements all respond 'BindMe' to @bind_tv@) such that</span><span>
</span><span id="line-464"></span><span class="hs-comment">-- @s(tys1)@ and that of @s(tys2)@ are equal, as witnessed by the returned</span><span>
</span><span id="line-465"></span><span class="hs-comment">-- Coercions. This version requires that the kinds of the types are the same,</span><span>
</span><span id="line-466"></span><span class="hs-comment">-- if you unify left-to-right.</span><span>
</span><span id="line-467"></span><span class="annot"><a href="GHC.Core.Unify.html#tcUnifyTysFG"><span class="hs-identifier hs-type">tcUnifyTysFG</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#BindFlag"><span class="hs-identifier hs-type">BindFlag</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-468"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-469"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UnifyResult"><span class="hs-identifier hs-type">UnifyResult</span></a></span><span>
</span><span id="line-470"></span><span id="tcUnifyTysFG"><span class="annot"><span class="annottext">tcUnifyTysFG :: (OutTyVar -&gt; BindFlag) -&gt; [Type] -&gt; [Type] -&gt; UnifyResult
</span><a href="GHC.Core.Unify.html#tcUnifyTysFG"><span class="hs-identifier hs-var hs-var">tcUnifyTysFG</span></a></span></span><span> </span><span id="local-6989586621680854166"><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854166"><span class="hs-identifier hs-var">bind_fn</span></a></span></span><span> </span><span id="local-6989586621680854165"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854165"><span class="hs-identifier hs-var">tys1</span></a></span></span><span> </span><span id="local-6989586621680854164"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854164"><span class="hs-identifier hs-var">tys2</span></a></span></span><span>
</span><span id="line-471"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; (OutTyVar -&gt; BindFlag) -&gt; [Type] -&gt; [Type] -&gt; UnifyResult
</span><a href="GHC.Core.Unify.html#tc_unify_tys_fg"><span class="hs-identifier hs-var">tc_unify_tys_fg</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854166"><span class="hs-identifier hs-var">bind_fn</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854165"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854164"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-472"></span><span>
</span><span id="line-473"></span><span class="annot"><a href="GHC.Core.Unify.html#tcUnifyTyKisFG"><span class="hs-identifier hs-type">tcUnifyTyKisFG</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#BindFlag"><span class="hs-identifier hs-type">BindFlag</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-474"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-475"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UnifyResult"><span class="hs-identifier hs-type">UnifyResult</span></a></span><span>
</span><span id="line-476"></span><span id="tcUnifyTyKisFG"><span class="annot"><span class="annottext">tcUnifyTyKisFG :: (OutTyVar -&gt; BindFlag) -&gt; [Type] -&gt; [Type] -&gt; UnifyResult
</span><a href="GHC.Core.Unify.html#tcUnifyTyKisFG"><span class="hs-identifier hs-var hs-var">tcUnifyTyKisFG</span></a></span></span><span> </span><span id="local-6989586621680854162"><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854162"><span class="hs-identifier hs-var">bind_fn</span></a></span></span><span> </span><span id="local-6989586621680854161"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854161"><span class="hs-identifier hs-var">tys1</span></a></span></span><span> </span><span id="local-6989586621680854160"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854160"><span class="hs-identifier hs-var">tys2</span></a></span></span><span>
</span><span id="line-477"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; (OutTyVar -&gt; BindFlag) -&gt; [Type] -&gt; [Type] -&gt; UnifyResult
</span><a href="GHC.Core.Unify.html#tc_unify_tys_fg"><span class="hs-identifier hs-var">tc_unify_tys_fg</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854162"><span class="hs-identifier hs-var">bind_fn</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854161"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854160"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-478"></span><span>
</span><span id="line-479"></span><span class="annot"><a href="GHC.Core.Unify.html#tc_unify_tys_fg"><span class="hs-identifier hs-type">tc_unify_tys_fg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-480"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#BindFlag"><span class="hs-identifier hs-type">BindFlag</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-481"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-482"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UnifyResult"><span class="hs-identifier hs-type">UnifyResult</span></a></span><span>
</span><span id="line-483"></span><span id="tc_unify_tys_fg"><span class="annot"><span class="annottext">tc_unify_tys_fg :: Bool -&gt; (OutTyVar -&gt; BindFlag) -&gt; [Type] -&gt; [Type] -&gt; UnifyResult
</span><a href="GHC.Core.Unify.html#tc_unify_tys_fg"><span class="hs-identifier hs-var hs-var">tc_unify_tys_fg</span></a></span></span><span> </span><span id="local-6989586621680854159"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854159"><span class="hs-identifier hs-var">match_kis</span></a></span></span><span> </span><span id="local-6989586621680854158"><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854158"><span class="hs-identifier hs-var">bind_fn</span></a></span></span><span> </span><span id="local-6989586621680854157"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854157"><span class="hs-identifier hs-var">tys1</span></a></span></span><span> </span><span id="local-6989586621680854156"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854156"><span class="hs-identifier hs-var">tys2</span></a></span></span><span>
</span><span id="line-484"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680854155"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854155"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; BindFlag)
-&gt; Bool
-&gt; Bool
-&gt; Bool
-&gt; RnEnv2
-&gt; TvSubstEnv
-&gt; CvSubstEnv
-&gt; [Type]
-&gt; [Type]
-&gt; UnifyResultM (TvSubstEnv, CvSubstEnv)
</span><a href="GHC.Core.Unify.html#tc_unify_tys"><span class="hs-identifier hs-var">tc_unify_tys</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854158"><span class="hs-identifier hs-var">bind_fn</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854159"><span class="hs-identifier hs-var">match_kis</span></a></span><span> </span><span class="annot"><span class="annottext">RnEnv2
</span><a href="#local-6989586621680854154"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-485"></span><span>                                  </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#emptyTvSubstEnv"><span class="hs-identifier hs-var">emptyTvSubstEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="GHC.Core.TyCo.Subst.html#emptyCvSubstEnv"><span class="hs-identifier hs-var">emptyCvSubstEnv</span></a></span><span>
</span><span id="line-486"></span><span>                                  </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854157"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854156"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-487"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; UnifyResult
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(TCvSubst -&gt; UnifyResult) -&gt; TCvSubst -&gt; UnifyResult
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.Unify.html#niFixTCvSubst"><span class="hs-identifier hs-var">niFixTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854155"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-488"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-489"></span><span>    </span><span id="local-6989586621680854153"><span class="annot"><span class="annottext">vars :: VarSet
</span><a href="#local-6989586621680854153"><span class="hs-identifier hs-var hs-var">vars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypes"><span class="hs-identifier hs-var">tyCoVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854157"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypes"><span class="hs-identifier hs-var">tyCoVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854156"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-490"></span><span>    </span><span id="local-6989586621680854154"><span class="annot"><span class="annottext">env :: RnEnv2
</span><a href="#local-6989586621680854154"><span class="hs-identifier hs-var hs-var">env</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; RnEnv2
</span><a href="GHC.Types.Var.Env.html#mkRnEnv2"><span class="hs-identifier hs-var">mkRnEnv2</span></a></span><span> </span><span class="annot"><span class="annottext">(InScopeSet -&gt; RnEnv2) -&gt; InScopeSet -&gt; RnEnv2
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680854153"><span class="hs-identifier hs-var">vars</span></a></span><span>
</span><span id="line-491"></span><span>
</span><span id="line-492"></span><span class="hs-comment">-- | This function is actually the one to call the unifier -- a little</span><span>
</span><span id="line-493"></span><span class="hs-comment">-- too general for outside clients, though.</span><span>
</span><span id="line-494"></span><span class="annot"><a href="GHC.Core.Unify.html#tc_unify_tys"><span class="hs-identifier hs-type">tc_unify_tys</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#BindFlag"><span class="hs-identifier hs-type">BindFlag</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-495"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#AmIUnifying"><span class="hs-identifier hs-type">AmIUnifying</span></a></span><span> </span><span class="hs-comment">-- ^ True &lt;=&gt; unify; False &lt;=&gt; match</span><span>
</span><span id="line-496"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>        </span><span class="hs-comment">-- ^ True &lt;=&gt; doing an injectivity check</span><span>
</span><span id="line-497"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>        </span><span class="hs-comment">-- ^ True &lt;=&gt; treat the kinds as well</span><span>
</span><span id="line-498"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#RnEnv2"><span class="hs-identifier hs-type">RnEnv2</span></a></span><span>
</span><span id="line-499"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span>  </span><span class="hs-comment">-- ^ substitution to extend</span><span>
</span><span id="line-500"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span>
</span><span id="line-501"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-502"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UnifyResultM"><span class="hs-identifier hs-type">UnifyResultM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-503"></span><span class="hs-comment">-- NB: It's tempting to ASSERT here that, if we're not matching kinds, then</span><span>
</span><span id="line-504"></span><span class="hs-comment">-- the kinds of the types should be the same. However, this doesn't work,</span><span>
</span><span id="line-505"></span><span class="hs-comment">-- as the types may be a dependent telescope, where later types have kinds</span><span>
</span><span id="line-506"></span><span class="hs-comment">-- that mention variables occurring earlier in the list of types. Here's an</span><span>
</span><span id="line-507"></span><span class="hs-comment">-- example (from typecheck/should_fail/T12709):</span><span>
</span><span id="line-508"></span><span class="hs-comment">--   template: [rep :: RuntimeRep,       a :: TYPE rep]</span><span>
</span><span id="line-509"></span><span class="hs-comment">--   target:   [LiftedRep :: RuntimeRep, Int :: TYPE LiftedRep]</span><span>
</span><span id="line-510"></span><span class="hs-comment">-- We can see that matching the first pair will make the kinds of the second</span><span>
</span><span id="line-511"></span><span class="hs-comment">-- pair equal. Yet, we still don't need a separate pass to unify the kinds</span><span>
</span><span id="line-512"></span><span class="hs-comment">-- of these types, so it's appropriate to use the Ty variant of unification.</span><span>
</span><span id="line-513"></span><span class="hs-comment">-- See also Note [tcMatchTy vs tcMatchTyKi].</span><span>
</span><span id="line-514"></span><span id="tc_unify_tys"><span class="annot"><span class="annottext">tc_unify_tys :: (OutTyVar -&gt; BindFlag)
-&gt; Bool
-&gt; Bool
-&gt; Bool
-&gt; RnEnv2
-&gt; TvSubstEnv
-&gt; CvSubstEnv
-&gt; [Type]
-&gt; [Type]
-&gt; UnifyResultM (TvSubstEnv, CvSubstEnv)
</span><a href="GHC.Core.Unify.html#tc_unify_tys"><span class="hs-identifier hs-var hs-var">tc_unify_tys</span></a></span></span><span> </span><span id="local-6989586621680854151"><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854151"><span class="hs-identifier hs-var">bind_fn</span></a></span></span><span> </span><span id="local-6989586621680854150"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854150"><span class="hs-identifier hs-var">unif</span></a></span></span><span> </span><span id="local-6989586621680854149"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854149"><span class="hs-identifier hs-var">inj_check</span></a></span></span><span> </span><span id="local-6989586621680854148"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854148"><span class="hs-identifier hs-var">match_kis</span></a></span></span><span> </span><span id="local-6989586621680854147"><span class="annot"><span class="annottext">RnEnv2
</span><a href="#local-6989586621680854147"><span class="hs-identifier hs-var">rn_env</span></a></span></span><span> </span><span id="local-6989586621680854146"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854146"><span class="hs-identifier hs-var">tv_env</span></a></span></span><span> </span><span id="local-6989586621680854145"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854145"><span class="hs-identifier hs-var">cv_env</span></a></span></span><span> </span><span id="local-6989586621680854144"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854144"><span class="hs-identifier hs-var">tys1</span></a></span></span><span> </span><span id="local-6989586621680854143"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854143"><span class="hs-identifier hs-var">tys2</span></a></span></span><span>
</span><span id="line-515"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
-&gt; CvSubstEnv
-&gt; UM (TvSubstEnv, CvSubstEnv)
-&gt; UnifyResultM (TvSubstEnv, CvSubstEnv)
forall a. TvSubstEnv -&gt; CvSubstEnv -&gt; UM a -&gt; UnifyResultM a
</span><a href="GHC.Core.Unify.html#initUM"><span class="hs-identifier hs-var">initUM</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854146"><span class="hs-identifier hs-var">tv_env</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680854145"><span class="hs-identifier hs-var">cv_env</span></a></span><span> </span><span class="annot"><span class="annottext">(UM (TvSubstEnv, CvSubstEnv)
 -&gt; UnifyResultM (TvSubstEnv, CvSubstEnv))
-&gt; UM (TvSubstEnv, CvSubstEnv)
-&gt; UnifyResultM (TvSubstEnv, CvSubstEnv)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-516"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; UM () -&gt; UM ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854148"><span class="hs-identifier hs-var">match_kis</span></a></span><span> </span><span class="annot"><span class="annottext">(UM () -&gt; UM ()) -&gt; UM () -&gt; UM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-517"></span><span>         </span><span class="annot"><span class="annottext">UMEnv -&gt; [Type] -&gt; [Type] -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_tys"><span class="hs-identifier hs-var">unify_tys</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854139"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854138"><span class="hs-identifier hs-var">kis1</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854137"><span class="hs-identifier hs-var">kis2</span></a></span><span>
</span><span id="line-518"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; [Type] -&gt; [Type] -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_tys"><span class="hs-identifier hs-var">unify_tys</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854139"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854144"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854143"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-519"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span class="hs-special">,</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TvSubstEnv -&gt; CvSubstEnv -&gt; (TvSubstEnv, CvSubstEnv))
-&gt; UM TvSubstEnv -&gt; UM (CvSubstEnv -&gt; (TvSubstEnv, CvSubstEnv))
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">UM TvSubstEnv
</span><a href="GHC.Core.Unify.html#getTvSubstEnv"><span class="hs-identifier hs-var">getTvSubstEnv</span></a></span><span> </span><span class="annot"><span class="annottext">UM (CvSubstEnv -&gt; (TvSubstEnv, CvSubstEnv))
-&gt; UM CvSubstEnv -&gt; UM (TvSubstEnv, CvSubstEnv)
forall (f :: * -&gt; *) a b. Applicative f =&gt; f (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">UM CvSubstEnv
</span><a href="GHC.Core.Unify.html#getCvSubstEnv"><span class="hs-identifier hs-var">getCvSubstEnv</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-520"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-521"></span><span>    </span><span id="local-6989586621680854139"><span class="annot"><span class="annottext">env :: UMEnv
</span><a href="#local-6989586621680854139"><span class="hs-identifier hs-var hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv :: Bool -&gt; Bool -&gt; RnEnv2 -&gt; VarSet -&gt; (OutTyVar -&gt; BindFlag) -&gt; UMEnv
</span><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-type">UMEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">um_bind_fun :: OutTyVar -&gt; BindFlag
</span><a href="GHC.Core.Unify.html#um_bind_fun"><span class="hs-identifier hs-var">um_bind_fun</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; BindFlag
</span><a href="#local-6989586621680854151"><span class="hs-identifier hs-var">bind_fn</span></a></span><span>
</span><span id="line-522"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">um_skols :: VarSet
</span><a href="GHC.Core.Unify.html#um_skols"><span class="hs-identifier hs-var">um_skols</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span>
</span><span id="line-523"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">um_unif :: Bool
</span><a href="GHC.Core.Unify.html#um_unif"><span class="hs-identifier hs-var">um_unif</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854150"><span class="hs-identifier hs-var">unif</span></a></span><span>
</span><span id="line-524"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">um_inj_tf :: Bool
</span><a href="GHC.Core.Unify.html#um_inj_tf"><span class="hs-identifier hs-var">um_inj_tf</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854149"><span class="hs-identifier hs-var">inj_check</span></a></span><span>
</span><span id="line-525"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">um_rn_env :: RnEnv2
</span><a href="GHC.Core.Unify.html#um_rn_env"><span class="hs-identifier hs-var">um_rn_env</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RnEnv2
</span><a href="#local-6989586621680854147"><span class="hs-identifier hs-var">rn_env</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-526"></span><span>
</span><span id="line-527"></span><span>    </span><span id="local-6989586621680854138"><span class="annot"><span class="annottext">kis1 :: [Type]
</span><a href="#local-6989586621680854138"><span class="hs-identifier hs-var hs-var">kis1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; [Type] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Type
Type -&gt; Type
</span><a href="GHC.Core.Type.html#typeKind"><span class="hs-identifier hs-var">typeKind</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854144"><span class="hs-identifier hs-var">tys1</span></a></span><span>
</span><span id="line-528"></span><span>    </span><span id="local-6989586621680854137"><span class="annot"><span class="annottext">kis2 :: [Type]
</span><a href="#local-6989586621680854137"><span class="hs-identifier hs-var hs-var">kis2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; [Type] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Type
Type -&gt; Type
</span><a href="GHC.Core.Type.html#typeKind"><span class="hs-identifier hs-var">typeKind</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854143"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-529"></span><span>
</span><span id="line-530"></span><span id="local-6989586621680854530"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680854121"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680854530"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Unify.html#UnifyResultM"><span class="hs-identifier hs-type">UnifyResultM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680854530"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-531"></span><span>  </span><span id="local-6989586621680854117"><span class="annot"><span class="annottext">ppr :: UnifyResultM a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="annot"><span class="annottext">UnifyResultM a
</span><a href="GHC.Core.Unify.html#SurelyApart"><span class="hs-identifier hs-var">SurelyApart</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;SurelyApart&quot;</span></span><span>
</span><span id="line-532"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-type">Unifiable</span></a></span><span> </span><span id="local-6989586621680854114"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680854114"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Unifiable&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680854114"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-533"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Unify.html#MaybeApart"><span class="hs-identifier hs-type">MaybeApart</span></a></span><span> </span><span id="local-6989586621680854112"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680854112"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;MaybeApart&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680854112"><span class="hs-identifier hs-var">x</span></a></span></span><span>
</span><span id="line-534"></span><span>
</span><span id="line-535"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                Non-idempotent substitution
*                                                                      *
************************************************************************

Note [Non-idempotent substitution]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
During unification we use a TvSubstEnv/CvSubstEnv pair that is
  (a) non-idempotent
  (b) loop-free; ie repeatedly applying it yields a fixed point

Note [Finding the substitution fixpoint]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Finding the fixpoint of a non-idempotent substitution arising from a
unification is much trickier than it looks, because of kinds.  Consider
   T k (H k (f:k)) ~ T * (g:*)
If we unify, we get the substitution
   [ k -&gt; *
   , g -&gt; H k (f:k) ]
To make it idempotent we don't want to get just
   [ k -&gt; *
   , g -&gt; H * (f:k) ]
We also want to substitute inside f's kind, to get
   [ k -&gt; *
   , g -&gt; H k (f:*) ]
If we don't do this, we may apply the substitution to something,
and get an ill-formed type, i.e. one where typeKind will fail.
This happened, for example, in #9106.

It gets worse.  In #14164 we wanted to take the fixpoint of
this substitution
   [ xs_asV :-&gt; F a_aY6 (z_aY7 :: a_aY6)
                        (rest_aWF :: G a_aY6 (z_aY7 :: a_aY6))
   , a_aY6  :-&gt; a_aXQ ]

We have to apply the substitution for a_aY6 two levels deep inside
the invocation of F!  We don't have a function that recursively
applies substitutions inside the kinds of variable occurrences (and
probably rightly so).

So, we work as follows:

 1. Start with the current substitution (which we are
    trying to fixpoint
       [ xs :-&gt; F a (z :: a) (rest :: G a (z :: a))
       , a  :-&gt; b ]

 2. Take all the free vars of the range of the substitution:
       {a, z, rest, b}
    NB: the free variable finder closes over
    the kinds of variable occurrences

 3. If none are in the domain of the substitution, stop.
    We have found a fixpoint.

 4. Remove the variables that are bound by the substitution, leaving
       {z, rest, b}

 5. Do a topo-sort to put them in dependency order:
       [ b :: *, z :: a, rest :: G a z ]

 6. Apply the substitution left-to-right to the kinds of these
    tyvars, extending it each time with a new binding, so we
    finish up with
       [ xs   :-&gt; ..as before..
       , a    :-&gt; b
       , b    :-&gt; b    :: *
       , z    :-&gt; z    :: b
       , rest :-&gt; rest :: G b (z :: b) ]
    Note that rest now has the right kind

 7. Apply this extended substitution (once) to the range of
    the /original/ substitution.  (Note that we do the
    extended substitution would go on forever if you tried
    to find its fixpoint, because it maps z to z.)

 8. And go back to step 1

In Step 6 we use the free vars from Step 2 as the initial
in-scope set, because all of those variables appear in the
range of the substitution, so they must all be in the in-scope
set.  But NB that the type substitution engine does not look up
variables in the in-scope set; it is used only to ensure no
shadowing.
-}</span><span>
</span><span id="line-622"></span><span>
</span><span id="line-623"></span><span class="annot"><a href="GHC.Core.Unify.html#niFixTCvSubst"><span class="hs-identifier hs-type">niFixTCvSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-624"></span><span class="hs-comment">-- Find the idempotent fixed point of the non-idempotent substitution</span><span>
</span><span id="line-625"></span><span class="hs-comment">-- This is surprisingly tricky:</span><span>
</span><span id="line-626"></span><span class="hs-comment">--   see Note [Finding the substitution fixpoint]</span><span>
</span><span id="line-627"></span><span class="hs-comment">-- ToDo: use laziness instead of iteration?</span><span>
</span><span id="line-628"></span><span id="niFixTCvSubst"><span class="annot"><span class="annottext">niFixTCvSubst :: TvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.Unify.html#niFixTCvSubst"><span class="hs-identifier hs-var hs-var">niFixTCvSubst</span></a></span></span><span> </span><span id="local-6989586621680854111"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854111"><span class="hs-identifier hs-var">tenv</span></a></span></span><span>
</span><span id="line-629"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680854110"><span class="hs-identifier hs-var">not_fixpoint</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.Unify.html#niFixTCvSubst"><span class="hs-identifier hs-var">niFixTCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; TvSubstEnv -&gt; TvSubstEnv
forall a b. (a -&gt; b) -&gt; VarEnv a -&gt; VarEnv b
</span><a href="GHC.Types.Var.Env.html#mapVarEnv"><span class="hs-identifier hs-var">mapVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854107"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854111"><span class="hs-identifier hs-var">tenv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-630"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854107"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-631"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-632"></span><span>    </span><span class="annot"><a href="#local-6989586621680854106"><span class="hs-identifier hs-type">range_fvs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.FV.html#FV"><span class="hs-identifier hs-type">FV</span></a></span><span>
</span><span id="line-633"></span><span>    </span><span id="local-6989586621680854106"><span class="annot"><span class="annottext">range_fvs :: FV
</span><a href="#local-6989586621680854106"><span class="hs-identifier hs-var hs-var">range_fvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; FV
</span><a href="GHC.Core.TyCo.FVs.html#tyCoFVsOfTypes"><span class="hs-identifier hs-var">tyCoFVsOfTypes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv -&gt; [Type]
forall key elt. UniqFM key elt -&gt; [elt]
</span><a href="GHC.Types.Unique.FM.html#nonDetEltsUFM"><span class="hs-identifier hs-var">nonDetEltsUFM</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854111"><span class="hs-identifier hs-var">tenv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-634"></span><span>          </span><span class="hs-comment">-- It's OK to use nonDetEltsUFM here because the</span><span>
</span><span id="line-635"></span><span>          </span><span class="hs-comment">-- order of range_fvs, range_tvs is immaterial</span><span>
</span><span id="line-636"></span><span>
</span><span id="line-637"></span><span>    </span><span class="annot"><a href="#local-6989586621680854104"><span class="hs-identifier hs-type">range_tvs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-638"></span><span>    </span><span id="local-6989586621680854104"><span class="annot"><span class="annottext">range_tvs :: [OutTyVar]
</span><a href="#local-6989586621680854104"><span class="hs-identifier hs-var hs-var">range_tvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FV -&gt; [OutTyVar]
</span><a href="GHC.Utils.FV.html#fvVarList"><span class="hs-identifier hs-var">fvVarList</span></a></span><span> </span><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621680854106"><span class="hs-identifier hs-var">range_fvs</span></a></span><span>
</span><span id="line-639"></span><span>
</span><span id="line-640"></span><span>    </span><span id="local-6989586621680854110"><span class="annot"><span class="annottext">not_fixpoint :: Bool
</span><a href="#local-6989586621680854110"><span class="hs-identifier hs-var hs-var">not_fixpoint</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; Bool) -&gt; [OutTyVar] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; Bool
</span><a href="#local-6989586621680854102"><span class="hs-identifier hs-var">in_domain</span></a></span><span> </span><span class="annot"><span class="annottext">[OutTyVar]
</span><a href="#local-6989586621680854104"><span class="hs-identifier hs-var">range_tvs</span></a></span><span>
</span><span id="line-641"></span><span>    </span><span id="local-6989586621680854102"><span class="annot"><span class="annottext">in_domain :: OutTyVar -&gt; Bool
</span><a href="#local-6989586621680854102"><span class="hs-identifier hs-var hs-var">in_domain</span></a></span></span><span> </span><span id="local-6989586621680854101"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680854101"><span class="hs-identifier hs-var">tv</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680854101"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; TvSubstEnv -&gt; Bool
forall a. OutTyVar -&gt; VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#elemVarEnv"><span class="hs-operator hs-var">`elemVarEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854111"><span class="hs-identifier hs-var">tenv</span></a></span><span>
</span><span id="line-642"></span><span>
</span><span id="line-643"></span><span>    </span><span id="local-6989586621680854099"><span class="annot"><span class="annottext">free_tvs :: [OutTyVar]
</span><a href="#local-6989586621680854099"><span class="hs-identifier hs-var hs-var">free_tvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OutTyVar] -&gt; [OutTyVar]
</span><a href="GHC.Core.TyCo.FVs.html#scopedSort"><span class="hs-identifier hs-var">scopedSort</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(OutTyVar -&gt; Bool) -&gt; [OutTyVar] -&gt; [OutTyVar]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="GHC.Utils.Misc.html#filterOut"><span class="hs-identifier hs-var">filterOut</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; Bool
</span><a href="#local-6989586621680854102"><span class="hs-identifier hs-var">in_domain</span></a></span><span> </span><span class="annot"><span class="annottext">[OutTyVar]
</span><a href="#local-6989586621680854104"><span class="hs-identifier hs-var">range_tvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-644"></span><span>
</span><span id="line-645"></span><span>    </span><span class="hs-comment">-- See Note [Finding the substitution fixpoint], Step 6</span><span>
</span><span id="line-646"></span><span>    </span><span id="local-6989586621680854096"><span class="annot"><span class="annottext">init_in_scope :: InScopeSet
</span><a href="#local-6989586621680854096"><span class="hs-identifier hs-var hs-var">init_in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FV -&gt; VarSet
</span><a href="GHC.Utils.FV.html#fvVarSet"><span class="hs-identifier hs-var">fvVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">FV
</span><a href="#local-6989586621680854106"><span class="hs-identifier hs-var">range_fvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-647"></span><span>    </span><span id="local-6989586621680854107"><span class="annot"><span class="annottext">subst :: TCvSubst
</span><a href="#local-6989586621680854107"><span class="hs-identifier hs-var hs-var">subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TCvSubst -&gt; OutTyVar -&gt; TCvSubst)
-&gt; TCvSubst -&gt; [OutTyVar] -&gt; TCvSubst
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; OutTyVar -&gt; TCvSubst
</span><a href="#local-6989586621680854093"><span class="hs-identifier hs-var">add_free_tv</span></a></span><span>
</span><span id="line-648"></span><span>                  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; TvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkTvSubst"><span class="hs-identifier hs-var">mkTvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680854096"><span class="hs-identifier hs-var">init_in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854111"><span class="hs-identifier hs-var">tenv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-649"></span><span>                  </span><span class="annot"><span class="annottext">[OutTyVar]
</span><a href="#local-6989586621680854099"><span class="hs-identifier hs-var">free_tvs</span></a></span><span>
</span><span id="line-650"></span><span>
</span><span id="line-651"></span><span>    </span><span class="annot"><a href="#local-6989586621680854093"><span class="hs-identifier hs-type">add_free_tv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-652"></span><span>    </span><span id="local-6989586621680854093"><span class="annot"><span class="annottext">add_free_tv :: TCvSubst -&gt; OutTyVar -&gt; TCvSubst
</span><a href="#local-6989586621680854093"><span class="hs-identifier hs-var hs-var">add_free_tv</span></a></span></span><span> </span><span id="local-6989586621680854092"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854092"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680854091"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680854091"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-653"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; OutTyVar -&gt; Type -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTvSubst"><span class="hs-identifier hs-var">extendTvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854092"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680854091"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OutTyVar -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680854088"><span class="hs-identifier hs-var">tv'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-654"></span><span>     </span><span class="hs-keyword">where</span><span>
</span><span id="line-655"></span><span>        </span><span id="local-6989586621680854088"><span class="annot"><span class="annottext">tv' :: OutTyVar
</span><a href="#local-6989586621680854088"><span class="hs-identifier hs-var hs-var">tv'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; OutTyVar -&gt; OutTyVar
</span><a href="GHC.Types.Var.html#updateTyVarKind"><span class="hs-identifier hs-var">updateTyVarKind</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854092"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680854091"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-656"></span><span>
</span><span id="line-657"></span><span class="annot"><a href="GHC.Core.Unify.html#niSubstTvSet"><span class="hs-identifier hs-type">niSubstTvSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyCoVarSet"><span class="hs-identifier hs-type">TyCoVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyCoVarSet"><span class="hs-identifier hs-type">TyCoVarSet</span></a></span><span>
</span><span id="line-658"></span><span class="hs-comment">-- Apply the non-idempotent substitution to a set of type variables,</span><span>
</span><span id="line-659"></span><span class="hs-comment">-- remembering that the substitution isn't necessarily idempotent</span><span>
</span><span id="line-660"></span><span class="hs-comment">-- This is used in the occurs check, before extending the substitution</span><span>
</span><span id="line-661"></span><span id="niSubstTvSet"><span class="annot"><span class="annottext">niSubstTvSet :: TvSubstEnv -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Core.Unify.html#niSubstTvSet"><span class="hs-identifier hs-var hs-var">niSubstTvSet</span></a></span></span><span> </span><span id="local-6989586621680854083"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854083"><span class="hs-identifier hs-var">tsubst</span></a></span></span><span> </span><span id="local-6989586621680854082"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680854082"><span class="hs-identifier hs-var">tvs</span></a></span></span><span>
</span><span id="line-662"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; VarSet -&gt; VarSet) -&gt; VarSet -&gt; VarSet -&gt; VarSet
forall elt a. (elt -&gt; a -&gt; a) -&gt; a -&gt; UniqSet elt -&gt; a
</span><a href="GHC.Types.Unique.Set.html#nonDetStrictFoldUniqSet"><span class="hs-identifier hs-var">nonDetStrictFoldUniqSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-identifier hs-var">unionVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; VarSet -&gt; VarSet)
-&gt; (OutTyVar -&gt; VarSet) -&gt; OutTyVar -&gt; VarSet -&gt; VarSet
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; VarSet
</span><a href="#local-6989586621680854079"><span class="hs-identifier hs-var">get</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680854082"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-663"></span><span>  </span><span class="hs-comment">-- It's OK to use a non-deterministic fold here because we immediately forget</span><span>
</span><span id="line-664"></span><span>  </span><span class="hs-comment">-- the ordering by creating a set.</span><span>
</span><span id="line-665"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-666"></span><span>    </span><span id="local-6989586621680854079"><span class="annot"><span class="annottext">get :: OutTyVar -&gt; VarSet
</span><a href="#local-6989586621680854079"><span class="hs-identifier hs-var hs-var">get</span></a></span></span><span> </span><span id="local-6989586621680854078"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680854078"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-667"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680854077"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854077"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; OutTyVar -&gt; Maybe Type
forall a. VarEnv a -&gt; OutTyVar -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854083"><span class="hs-identifier hs-var">tsubst</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680854078"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-668"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Core.Unify.html#niSubstTvSet"><span class="hs-identifier hs-var">niSubstTvSet</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680854083"><span class="hs-identifier hs-var">tsubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854077"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-669"></span><span>
</span><span id="line-670"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-671"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unitVarSet"><span class="hs-identifier hs-var">unitVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680854078"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-672"></span><span>
</span><span id="line-673"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                unify_ty: the main workhorse
*                                                                      *
************************************************************************

Note [Specification of unification]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The pure unifier, unify_ty, defined in this module, tries to work out
a substitution to make two types say True to eqType. NB: eqType is
itself not purely syntactic; it accounts for CastTys;
see Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep

Unlike the &quot;impure unifiers&quot; in the typechecker (the eager unifier in
GHC.Tc.Utils.Unify, and the constraint solver itself in GHC.Tc.Solver.Canonical), the pure
unifier It does /not/ work up to ~.

The algorithm implemented here is rather delicate, and we depend on it
to uphold certain properties. This is a summary of these required
properties. Any reference to &quot;flattening&quot; refers to the flattening
algorithm in GHC.Core.FamInstEnv (See Note [Flattening] in GHC.Core.FamInstEnv), not
the flattening algorithm in the solver.

Notation:
 &#952;,&#966;    substitutions
 &#958;    type-function-free types
 &#964;,&#963;  other types
 &#964;&#9837;   type &#964;, flattened

 &#8801;    eqType

(U1) Soundness.
     If (unify &#964;&#8321; &#964;&#8322;) = Unifiable &#952;, then &#952;(&#964;&#8321;) &#8801; &#952;(&#964;&#8322;).
     &#952; is a most general unifier for &#964;&#8321; and &#964;&#8322;.

(U2) Completeness.
     If (unify &#958;&#8321; &#958;&#8322;) = SurelyApart,
     then there exists no substitution &#952; such that &#952;(&#958;&#8321;) &#8801; &#952;(&#958;&#8322;).

These two properties are stated as Property 11 in the &quot;Closed Type Families&quot;
paper (POPL'14). Below, this paper is called [CTF].

(U3) Apartness under substitution.
     If (unify &#958; &#964;&#9837;) = SurelyApart, then (unify &#958; &#952;(&#964;)&#9837;) = SurelyApart,
     for any &#952;. (Property 12 from [CTF])

(U4) Apart types do not unify.
     If (unify &#958; &#964;&#9837;) = SurelyApart, then there exists no &#952;
     such that &#952;(&#958;) = &#952;(&#964;). (Property 13 from [CTF])

THEOREM. Completeness w.r.t ~
    If (unify &#964;&#8321;&#9837; &#964;&#8322;&#9837;) = SurelyApart,
    then there exists no proof that (&#964;&#8321; ~ &#964;&#8322;).

PROOF. See appendix of [CTF].


The unification algorithm is used for type family injectivity, as described
in the &quot;Injective Type Families&quot; paper (Haskell'15), called [ITF]. When run
in this mode, it has the following properties.

(I1) If (unify &#963; &#964;) = SurelyApart, then &#963; and &#964; are not unifiable, even
     after arbitrary type family reductions. Note that &#963; and &#964; are
     not flattened here.

(I2) If (unify &#963; &#964;) = MaybeApart &#952;, and if some
     &#966; exists such that &#966;(&#963;) ~ &#966;(&#964;), then &#966; extends &#952;.


Furthermore, the RULES matching algorithm requires this property,
but only when using this algorithm for matching:

(M1) If (match &#963; &#964;) succeeds with &#952;, then all matchable tyvars
     in &#963; are bound in &#952;.

     Property M1 means that we must extend the substitution with,
     say (a &#8614; a) when appropriate during matching.
     See also Note [Self-substitution when matching].

(M2) Completeness of matching.
     If &#952;(&#963;) = &#964;, then (match &#963; &#964;) = Unifiable &#966;,
     where &#952; is an extension of &#966;.

Sadly, property M2 and I2 conflict. Consider

type family F1 a b where
  F1 Int    Bool   = Char
  F1 Double String = Char

Consider now two matching problems:

P1. match (F1 a Bool) (F1 Int Bool)
P2. match (F1 a Bool) (F1 Double String)

In case P1, we must find (a &#8614; Int) to satisfy M2.
In case P2, we must /not/ find (a &#8614; Double), in order to satisfy I2. (Note
that the correct mapping for I2 is (a &#8614; Int). There is no way to discover
this, but we mustn't map a to anything else!)

We thus must parameterize the algorithm over whether it's being used
for an injectivity check (refrain from looking at non-injective arguments
to type families) or not (do indeed look at those arguments).  This is
implemented  by the uf_inj_tf field of UmEnv.

(It's all a question of whether or not to include equation (7) from Fig. 2
of [ITF].)

This extra parameter is a bit fiddly, perhaps, but seemingly less so than
having two separate, almost-identical algorithms.

Note [Self-substitution when matching]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
What should happen when we're *matching* (not unifying) a1 with a1? We
should get a substitution [a1 |-&gt; a1]. A successful match should map all
the template variables (except ones that disappear when expanding synonyms).
But when unifying, we don't want to do this, because we'll then fall into
a loop.

This arrangement affects the code in three places:
 - If we're matching a refined template variable, don't recur. Instead, just
   check for equality. That is, if we know [a |-&gt; Maybe a] and are matching
   (a ~? Maybe Int), we want to just fail.

 - Skip the occurs check when matching. This comes up in two places, because
   matching against variables is handled separately from matching against
   full-on types.

Note that this arrangement was provoked by a real failure, where the same
unique ended up in the template as in the target. (It was a rule firing when
compiling Data.List.NonEmpty.)

Note [Matching coercion variables]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this:

   type family F a

   data G a where
     MkG :: F a ~ Bool =&gt; G a

   type family Foo (x :: G a) :: F a
   type instance Foo MkG = False

We would like that to be accepted. For that to work, we need to introduce
a coercion variable on the left and then use it on the right. Accordingly,
at use sites of Foo, we need to be able to use matching to figure out the
value for the coercion. (See the desugared version:

   axFoo :: [a :: *, c :: F a ~ Bool]. Foo (MkG c) = False |&gt; (sym c)

) We never want this action to happen during *unification* though, when
all bets are off.

Note [Kind coercions in Unify]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We wish to match/unify while ignoring casts. But, we can't just ignore
them completely, or we'll end up with ill-kinded substitutions. For example,
say we're matching `a` with `ty |&gt; co`. If we just drop the cast, we'll
return [a |-&gt; ty], but `a` and `ty` might have different kinds. We can't
just match/unify their kinds, either, because this might gratuitously
fail. After all, `co` is the witness that the kinds are the same -- they
may look nothing alike.

So, we pass a kind coercion to the match/unify worker. This coercion witnesses
the equality between the substed kind of the left-hand type and the substed
kind of the right-hand type. Note that we do not unify kinds at the leaves
(as we did previously). We thus have

INVARIANT: In the call
    unify_ty ty1 ty2 kco
it must be that subst(kco) :: subst(kind(ty1)) ~N subst(kind(ty2)), where
`subst` is the ambient substitution in the UM monad.

To get this coercion, we first have to match/unify
the kinds before looking at the types. Happily, we need look only one level
up, as all kinds are guaranteed to have kind *.

When we're working with type applications (either TyConApp or AppTy) we
need to worry about establishing INVARIANT, as the kinds of the function
&amp; arguments aren't (necessarily) included in the kind of the result.
When unifying two TyConApps, this is easy, because the two TyCons are
the same. Their kinds are thus the same. As long as we unify left-to-right,
we'll be sure to unify types' kinds before the types themselves. (For example,
think about Proxy :: forall k. k -&gt; *. Unifying the first args matches up
the kinds of the second args.)

For AppTy, we must unify the kinds of the functions, but once these are
unified, we can continue unifying arguments without worrying further about
kinds.

The interface to this module includes both &quot;...Ty&quot; functions and
&quot;...TyKi&quot; functions. The former assume that INVARIANT is already
established, either because the kinds are the same or because the
list of types being passed in are the well-typed arguments to some
type constructor (see two paragraphs above). The latter take a separate
pre-pass over the kinds to establish INVARIANT. Sometimes, it's important
not to take the second pass, as it caused #12442.

We thought, at one point, that this was all unnecessary: why should
casts be in types in the first place? But they are sometimes. In
dependent/should_compile/KindEqualities2, we see, for example the
constraint Num (Int |&gt; (blah ; sym blah)).  We naturally want to find
a dictionary for that constraint, which requires dealing with
coercions in this manner.

Note [Matching in the presence of casts (1)]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When matching, it is crucial that no variables from the template
end up in the range of the matching substitution (obviously!).
When unifying, that's not a constraint; instead we take the fixpoint
of the substitution at the end.

So what should we do with this, when matching?
   unify_ty (tmpl |&gt; co) tgt kco

Previously, wrongly, we pushed 'co' in the (horrid) accumulating
'kco' argument like this:
   unify_ty (tmpl |&gt; co) tgt kco
     = unify_ty tmpl tgt (kco ; co)

But that is obviously wrong because 'co' (from the template) ends
up in 'kco', which in turn ends up in the range of the substitution.

This all came up in #13910.  Because we match tycon arguments
left-to-right, the ambient substitution will already have a matching
substitution for any kinds; so there is an easy fix: just apply
the substitution-so-far to the coercion from the LHS.

Note that

* When matching, the first arg of unify_ty is always the template;
  we never swap round.

* The above argument is distressingly indirect. We seek a
  better way.

* One better way is to ensure that type patterns (the template
  in the matching process) have no casts.  See #14119.

Note [Matching in the presence of casts (2)]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There is another wrinkle (#17395).  Suppose (T :: forall k. k -&gt; Type)
and we are matching
   tcMatchTy (T k (a::k))  (T j (b::j))

Then we'll match k :-&gt; j, as expected. But then in unify_tys
we invoke
   unify_tys env (a::k) (b::j) (Refl j)

Although we have unified k and j, it's very important that we put
(Refl j), /not/ (Refl k) as the fourth argument to unify_tys.
If we put (Refl k) we'd end up with the substitution
  a :-&gt; b |&gt; Refl k
which is bogus because one of the template variables, k,
appears in the range of the substitution.  Eek.

Similar care is needed in unify_ty_app.


Note [Polykinded tycon applications]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose  T :: forall k. Type -&gt; K
and we are unifying
  ty1:  T @Type         Int       :: Type
  ty2:  T @(Type-&gt;Type) Int Int   :: Type

These two TyConApps have the same TyCon at the front but they
(legitimately) have different numbers of arguments.  They
are surelyApart, so we can report that without looking any
further (see #15704).
-}</span><span>
</span><span id="line-945"></span><span>
</span><span id="line-946"></span><span class="hs-comment">-------------- unify_ty: the main workhorse -----------</span><span>
</span><span id="line-947"></span><span>
</span><span id="line-948"></span><span class="hs-keyword">type</span><span> </span><span id="AmIUnifying"><span class="annot"><a href="GHC.Core.Unify.html#AmIUnifying"><span class="hs-identifier hs-var">AmIUnifying</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>   </span><span class="hs-comment">-- True  &lt;=&gt; Unifying</span><span>
</span><span id="line-949"></span><span>                          </span><span class="hs-comment">-- False &lt;=&gt; Matching</span><span>
</span><span id="line-950"></span><span>
</span><span id="line-951"></span><span class="annot"><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-type">unify_ty</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-type">UMEnv</span></a></span><span>
</span><span id="line-952"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>  </span><span class="hs-comment">-- Types to be unified and a co</span><span>
</span><span id="line-953"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionN"><span class="hs-identifier hs-type">CoercionN</span></a></span><span>     </span><span class="hs-comment">-- A coercion between their kinds</span><span>
</span><span id="line-954"></span><span>                          </span><span class="hs-comment">-- See Note [Kind coercions in Unify]</span><span>
</span><span id="line-955"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-956"></span><span class="hs-comment">-- See Note [Specification of unification]</span><span>
</span><span id="line-957"></span><span class="hs-comment">-- Respects newtypes, PredTypes</span><span>
</span><span id="line-958"></span><span>
</span><span id="line-959"></span><span id="unify_ty"><span class="annot"><span class="annottext">unify_ty :: UMEnv -&gt; Type -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var hs-var">unify_ty</span></a></span></span><span> </span><span id="local-6989586621680854071"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854071"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680854070"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854070"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621680854069"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854069"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span id="local-6989586621680854068"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854068"><span class="hs-identifier hs-var">kco</span></a></span></span><span>
</span><span id="line-960"></span><span>    </span><span class="hs-comment">-- TODO: More commentary needed here</span><span>
</span><span id="line-961"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680854067"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854067"><span class="hs-identifier hs-var">ty1'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe Type
</span><a href="GHC.Core.Type.html#tcView"><span class="hs-identifier hs-var">tcView</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854070"><span class="hs-identifier hs-var">ty1</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Type -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854071"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854067"><span class="hs-identifier hs-var">ty1'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854069"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854068"><span class="hs-identifier hs-var">kco</span></a></span><span>
</span><span id="line-962"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680854065"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854065"><span class="hs-identifier hs-var">ty2'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe Type
</span><a href="GHC.Core.Type.html#tcView"><span class="hs-identifier hs-var">tcView</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854069"><span class="hs-identifier hs-var">ty2</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Type -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854071"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854070"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854065"><span class="hs-identifier hs-var">ty2'</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854068"><span class="hs-identifier hs-var">kco</span></a></span><span>
</span><span id="line-963"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CastTy"><span class="hs-identifier hs-type">CastTy</span></a></span><span> </span><span id="local-6989586621680854063"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854063"><span class="hs-identifier hs-var">ty1'</span></a></span></span><span> </span><span id="local-6989586621680854062"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854062"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854070"><span class="hs-identifier hs-var">ty1</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Bool
</span><a href="GHC.Core.Unify.html#um_unif"><span class="hs-identifier hs-var hs-var">um_unif</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854071"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-964"></span><span>                                </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Type -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854071"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854063"><span class="hs-identifier hs-var">ty1'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854069"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854062"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkTransCo"><span class="hs-operator hs-var">`mkTransCo`</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854068"><span class="hs-identifier hs-var">kco</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-965"></span><span>                                </span><span class="hs-keyword">else</span><span> </span><span class="hs-comment">-- See Note [Matching in the presence of casts (1)]</span><span>
</span><span id="line-966"></span><span>                                     </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680854060"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854060"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; UM TCvSubst
</span><a href="GHC.Core.Unify.html#getSubst"><span class="hs-identifier hs-var">getSubst</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854071"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-967"></span><span>                                        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680854056"><span class="annot"><span class="annottext">co' :: Coercion
</span><a href="#local-6989586621680854056"><span class="hs-identifier hs-var hs-var">co'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Coercion -&gt; Coercion
TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCo"><span class="hs-identifier hs-var">substCo</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680854060"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854062"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-968"></span><span>                                        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Type -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854071"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854063"><span class="hs-identifier hs-var">ty1'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854069"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854056"><span class="hs-identifier hs-var">co'</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkTransCo"><span class="hs-operator hs-var">`mkTransCo`</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854068"><span class="hs-identifier hs-var">kco</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-969"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CastTy"><span class="hs-identifier hs-type">CastTy</span></a></span><span> </span><span id="local-6989586621680854054"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854054"><span class="hs-identifier hs-var">ty2'</span></a></span></span><span> </span><span id="local-6989586621680854053"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854053"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854069"><span class="hs-identifier hs-var">ty2</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Type -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854071"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854070"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854054"><span class="hs-identifier hs-var">ty2'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854068"><span class="hs-identifier hs-var">kco</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkTransCo"><span class="hs-operator hs-var">`mkTransCo`</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkSymCo"><span class="hs-identifier hs-var">mkSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854053"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-970"></span><span>
</span><span id="line-971"></span><span class="annot"><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span id="local-6989586621680854051"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854051"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621680854049"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680854049"><span class="hs-identifier hs-var">tv1</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680854048"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854048"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span id="local-6989586621680854047"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854047"><span class="hs-identifier hs-var">kco</span></a></span></span><span>
</span><span id="line-972"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#uVar"><span class="hs-identifier hs-var">uVar</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854051"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680854049"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854048"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854047"><span class="hs-identifier hs-var">kco</span></a></span><span>
</span><span id="line-973"></span><span class="annot"><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span id="local-6989586621680854045"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854045"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680854044"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854044"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621680854043"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680854043"><span class="hs-identifier hs-var">tv2</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680854042"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854042"><span class="hs-identifier hs-var">kco</span></a></span></span><span>
</span><span id="line-974"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Bool
</span><a href="GHC.Core.Unify.html#um_unif"><span class="hs-identifier hs-var hs-var">um_unif</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854045"><span class="hs-identifier hs-var">env</span></a></span><span>  </span><span class="hs-comment">-- If unifying, can swap args</span><span>
</span><span id="line-975"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#uVar"><span class="hs-identifier hs-var">uVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMEnv -&gt; UMEnv
</span><a href="GHC.Core.Unify.html#umSwapRn"><span class="hs-identifier hs-var">umSwapRn</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854045"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680854043"><span class="hs-identifier hs-var">tv2</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854044"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkSymCo"><span class="hs-identifier hs-var">mkSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854042"><span class="hs-identifier hs-var">kco</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-976"></span><span>
</span><span id="line-977"></span><span class="annot"><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span id="local-6989586621680854040"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854040"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680854039"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854039"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621680854038"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854038"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span id="local-6989586621680854037"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680854037"><span class="hs-identifier hs-var">_kco</span></a></span></span><span>
</span><span id="line-978"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680854036"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854036"><span class="hs-identifier hs-var">tc1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680854035"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854035"><span class="hs-identifier hs-var">tys1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (TyCon, [Type])
</span><a href="#local-6989586621680854034"><span class="hs-identifier hs-var">mb_tc_app1</span></a></span><span>
</span><span id="line-979"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680854033"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854033"><span class="hs-identifier hs-var">tc2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680854032"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854032"><span class="hs-identifier hs-var">tys2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (TyCon, [Type])
</span><a href="#local-6989586621680854031"><span class="hs-identifier hs-var">mb_tc_app2</span></a></span><span>
</span><span id="line-980"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854036"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854033"><span class="hs-identifier hs-var">tc2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.Type.html#tcIsLiftedTypeKind"><span class="hs-identifier hs-var">tcIsLiftedTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854039"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.Type.html#tcIsLiftedTypeKind"><span class="hs-identifier hs-var">tcIsLiftedTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854038"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-981"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Role -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isInjectiveTyCon"><span class="hs-identifier hs-var">isInjectiveTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854036"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span>
</span><span id="line-982"></span><span>    </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; [Type] -&gt; [Type] -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_tys"><span class="hs-identifier hs-var">unify_tys</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854040"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854035"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854032"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-983"></span><span>    </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680854026"><span class="annot"><span class="annottext">inj :: [Bool]
</span><a href="#local-6989586621680854026"><span class="hs-identifier hs-var hs-var">inj</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isTypeFamilyTyCon"><span class="hs-identifier hs-var">isTypeFamilyTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854036"><span class="hs-identifier hs-var">tc1</span></a></span><span>
</span><span id="line-984"></span><span>                      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Injectivity
</span><a href="GHC.Core.TyCon.html#tyConInjectivityInfo"><span class="hs-identifier hs-var">tyConInjectivityInfo</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854036"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-985"></span><span>                               </span><span class="annot"><span class="annottext">Injectivity
</span><a href="GHC.Core.TyCon.html#NotInjective"><span class="hs-identifier hs-var">NotInjective</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; [Bool]
forall a. a -&gt; [a]
</span><a href="../../base/src/GHC.List.html#repeat"><span class="hs-identifier hs-var">repeat</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-986"></span><span>                               </span><span class="annot"><a href="GHC.Core.TyCon.html#Injective"><span class="hs-identifier hs-type">Injective</span></a></span><span> </span><span id="local-6989586621680854020"><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621680854020"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621680854020"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-987"></span><span>                      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-988"></span><span>                      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; [Bool]
forall a. a -&gt; [a]
</span><a href="../../base/src/GHC.List.html#repeat"><span class="hs-identifier hs-var">repeat</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-989"></span><span>
</span><span id="line-990"></span><span>                  </span><span class="hs-special">(</span><span id="local-6989586621680854019"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854019"><span class="hs-identifier hs-var">inj_tys1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680854018"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854018"><span class="hs-identifier hs-var">noninj_tys1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Bool] -&gt; [Type] -&gt; ([Type], [Type])
forall a. [Bool] -&gt; [a] -&gt; ([a], [a])
</span><a href="GHC.Utils.Misc.html#partitionByList"><span class="hs-identifier hs-var">partitionByList</span></a></span><span> </span><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621680854026"><span class="hs-identifier hs-var">inj</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854035"><span class="hs-identifier hs-var">tys1</span></a></span><span>
</span><span id="line-991"></span><span>                  </span><span class="hs-special">(</span><span id="local-6989586621680854016"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854016"><span class="hs-identifier hs-var">inj_tys2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680854015"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854015"><span class="hs-identifier hs-var">noninj_tys2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Bool] -&gt; [Type] -&gt; ([Type], [Type])
forall a. [Bool] -&gt; [a] -&gt; ([a], [a])
</span><a href="GHC.Utils.Misc.html#partitionByList"><span class="hs-identifier hs-var">partitionByList</span></a></span><span> </span><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621680854026"><span class="hs-identifier hs-var">inj</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854032"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-992"></span><span>
</span><span id="line-993"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; [Type] -&gt; [Type] -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_tys"><span class="hs-identifier hs-var">unify_tys</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854040"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854019"><span class="hs-identifier hs-var">inj_tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854016"><span class="hs-identifier hs-var">inj_tys2</span></a></span><span>
</span><span id="line-994"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; UM () -&gt; UM ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMEnv -&gt; Bool
</span><a href="GHC.Core.Unify.html#um_inj_tf"><span class="hs-identifier hs-var hs-var">um_inj_tf</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854040"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(UM () -&gt; UM ()) -&gt; UM () -&gt; UM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-comment">-- See (end of) Note [Specification of unification]</span><span>
</span><span id="line-995"></span><span>              </span><span class="annot"><span class="annottext">UM () -&gt; UM ()
</span><a href="GHC.Core.Unify.html#don%27tBeSoSure"><span class="hs-identifier hs-var">don'tBeSoSure</span></a></span><span> </span><span class="annot"><span class="annottext">(UM () -&gt; UM ()) -&gt; UM () -&gt; UM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; [Type] -&gt; [Type] -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_tys"><span class="hs-identifier hs-var">unify_tys</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854040"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854018"><span class="hs-identifier hs-var">noninj_tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680854015"><span class="hs-identifier hs-var">noninj_tys2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-996"></span><span>
</span><span id="line-997"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680854012"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854012"><span class="hs-identifier hs-var">tc1</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (TyCon, [Type])
</span><a href="#local-6989586621680854034"><span class="hs-identifier hs-var">mb_tc_app1</span></a></span><span>
</span><span id="line-998"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Role -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isGenerativeTyCon"><span class="hs-identifier hs-var">isGenerativeTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854012"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-999"></span><span>    </span><span class="hs-comment">-- E.g.   unify_ty (F ty1) b  =  MaybeApart</span><span>
</span><span id="line-1000"></span><span>    </span><span class="hs-comment">--        because the (F ty1) behaves like a variable</span><span>
</span><span id="line-1001"></span><span>    </span><span class="hs-comment">--        NB: if unifying, we have already dealt</span><span>
</span><span id="line-1002"></span><span>    </span><span class="hs-comment">--            with the 'ty2 = variable' case</span><span>
</span><span id="line-1003"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UM ()
</span><a href="GHC.Core.Unify.html#maybeApart"><span class="hs-identifier hs-var">maybeApart</span></a></span><span>
</span><span id="line-1004"></span><span>
</span><span id="line-1005"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680854008"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854008"><span class="hs-identifier hs-var">tc2</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (TyCon, [Type])
</span><a href="#local-6989586621680854031"><span class="hs-identifier hs-var">mb_tc_app2</span></a></span><span>
</span><span id="line-1006"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Role -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isGenerativeTyCon"><span class="hs-identifier hs-var">isGenerativeTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680854008"><span class="hs-identifier hs-var">tc2</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1007"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Bool
</span><a href="GHC.Core.Unify.html#um_unif"><span class="hs-identifier hs-var hs-var">um_unif</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854040"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-1008"></span><span>    </span><span class="hs-comment">-- E.g.   unify_ty [a] (F ty2) =  MaybeApart, when unifying (only)</span><span>
</span><span id="line-1009"></span><span>    </span><span class="hs-comment">--        because the (F ty2) behaves like a variable</span><span>
</span><span id="line-1010"></span><span>    </span><span class="hs-comment">--        NB: we have already dealt with the 'ty1 = variable' case</span><span>
</span><span id="line-1011"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UM ()
</span><a href="GHC.Core.Unify.html#maybeApart"><span class="hs-identifier hs-var">maybeApart</span></a></span><span>
</span><span id="line-1012"></span><span>
</span><span id="line-1013"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1014"></span><span>    </span><span id="local-6989586621680854034"><span class="annot"><span class="annottext">mb_tc_app1 :: Maybe (TyCon, [Type])
</span><a href="#local-6989586621680854034"><span class="hs-identifier hs-var hs-var">mb_tc_app1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; Type -&gt; Maybe (TyCon, [Type])
Type -&gt; Maybe (TyCon, [Type])
</span><a href="GHC.Core.Type.html#tcSplitTyConApp_maybe"><span class="hs-identifier hs-var">tcSplitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854039"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1015"></span><span>    </span><span id="local-6989586621680854031"><span class="annot"><span class="annottext">mb_tc_app2 :: Maybe (TyCon, [Type])
</span><a href="#local-6989586621680854031"><span class="hs-identifier hs-var hs-var">mb_tc_app2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; Type -&gt; Maybe (TyCon, [Type])
Type -&gt; Maybe (TyCon, [Type])
</span><a href="GHC.Core.Type.html#tcSplitTyConApp_maybe"><span class="hs-identifier hs-var">tcSplitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854038"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1016"></span><span>
</span><span id="line-1017"></span><span>        </span><span class="hs-comment">-- Applications need a bit of care!</span><span>
</span><span id="line-1018"></span><span>        </span><span class="hs-comment">-- They can match FunTy and TyConApp, so use splitAppTy_maybe</span><span>
</span><span id="line-1019"></span><span>        </span><span class="hs-comment">-- NB: we've already dealt with type variables,</span><span>
</span><span id="line-1020"></span><span>        </span><span class="hs-comment">-- so if one type is an App the other one jolly well better be too</span><span>
</span><span id="line-1021"></span><span class="annot"><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span id="local-6989586621680854002"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854002"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppTy"><span class="hs-identifier hs-type">AppTy</span></a></span><span> </span><span id="local-6989586621680854000"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854000"><span class="hs-identifier hs-var">ty1a</span></a></span></span><span> </span><span id="local-6989586621680853999"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853999"><span class="hs-identifier hs-var">ty1b</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680853998"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853998"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span id="local-6989586621680853997"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853997"><span class="hs-identifier hs-var">_kco</span></a></span></span><span>
</span><span id="line-1022"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853996"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853996"><span class="hs-identifier hs-var">ty2a</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853995"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853995"><span class="hs-identifier hs-var">ty2b</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (Type, Type)
</span><a href="GHC.Core.Type.html#tcRepSplitAppTy_maybe"><span class="hs-identifier hs-var">tcRepSplitAppTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853998"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1023"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Type -&gt; [Type] -&gt; Type -&gt; [Type] -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_ty_app"><span class="hs-identifier hs-var">unify_ty_app</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680854002"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680854000"><span class="hs-identifier hs-var">ty1a</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853999"><span class="hs-identifier hs-var">ty1b</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853996"><span class="hs-identifier hs-var">ty2a</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853995"><span class="hs-identifier hs-var">ty2b</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1024"></span><span>
</span><span id="line-1025"></span><span class="annot"><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span id="local-6989586621680853992"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853992"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680853991"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853991"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppTy"><span class="hs-identifier hs-type">AppTy</span></a></span><span> </span><span id="local-6989586621680853990"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853990"><span class="hs-identifier hs-var">ty2a</span></a></span></span><span> </span><span id="local-6989586621680853989"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853989"><span class="hs-identifier hs-var">ty2b</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680853988"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853988"><span class="hs-identifier hs-var">_kco</span></a></span></span><span>
</span><span id="line-1026"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853987"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853987"><span class="hs-identifier hs-var">ty1a</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853986"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853986"><span class="hs-identifier hs-var">ty1b</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (Type, Type)
</span><a href="GHC.Core.Type.html#tcRepSplitAppTy_maybe"><span class="hs-identifier hs-var">tcRepSplitAppTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853991"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1027"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Type -&gt; [Type] -&gt; Type -&gt; [Type] -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_ty_app"><span class="hs-identifier hs-var">unify_ty_app</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853992"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853987"><span class="hs-identifier hs-var">ty1a</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853986"><span class="hs-identifier hs-var">ty1b</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853990"><span class="hs-identifier hs-var">ty2a</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853989"><span class="hs-identifier hs-var">ty2b</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1028"></span><span>
</span><span id="line-1029"></span><span class="annot"><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LitTy"><span class="hs-identifier hs-type">LitTy</span></a></span><span> </span><span id="local-6989586621680853984"><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621680853984"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LitTy"><span class="hs-identifier hs-type">LitTy</span></a></span><span> </span><span id="local-6989586621680853983"><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621680853983"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680853982"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853982"><span class="hs-identifier hs-var">_kco</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621680853984"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">TyLit -&gt; TyLit -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621680853983"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; UM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1030"></span><span>
</span><span id="line-1031"></span><span class="annot"><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span id="local-6989586621680853981"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853981"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllTy"><span class="hs-identifier hs-type">ForAllTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-type">Bndr</span></a></span><span> </span><span id="local-6989586621680853978"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853978"><span class="hs-identifier hs-var">tv1</span></a></span></span><span> </span><span class="annot"><span class="annottext">ArgFlag
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680853977"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853977"><span class="hs-identifier hs-var">ty1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllTy"><span class="hs-identifier hs-type">ForAllTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-type">Bndr</span></a></span><span> </span><span id="local-6989586621680853976"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853976"><span class="hs-identifier hs-var">tv2</span></a></span></span><span> </span><span class="annot"><span class="annottext">ArgFlag
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680853975"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853975"><span class="hs-identifier hs-var">ty2</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680853974"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853974"><span class="hs-identifier hs-var">kco</span></a></span></span><span>
</span><span id="line-1032"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Type -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853981"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OutTyVar -&gt; Type
</span><a href="GHC.Types.Var.html#varType"><span class="hs-identifier hs-var hs-var">varType</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853978"><span class="hs-identifier hs-var">tv1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OutTyVar -&gt; Type
</span><a href="GHC.Types.Var.html#varType"><span class="hs-identifier hs-var hs-var">varType</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853976"><span class="hs-identifier hs-var">tv2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.html#liftedTypeKind"><span class="hs-identifier hs-var">liftedTypeKind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1033"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680853970"><span class="annot"><span class="annottext">env' :: UMEnv
</span><a href="#local-6989586621680853970"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; OutTyVar -&gt; UMEnv
</span><a href="GHC.Core.Unify.html#umRnBndr2"><span class="hs-identifier hs-var">umRnBndr2</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853981"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853978"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853976"><span class="hs-identifier hs-var">tv2</span></a></span><span>
</span><span id="line-1034"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Type -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853970"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853977"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853975"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853974"><span class="hs-identifier hs-var">kco</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1035"></span><span>
</span><span id="line-1036"></span><span class="hs-comment">-- See Note [Matching coercion variables]</span><span>
</span><span id="line-1037"></span><span class="annot"><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span id="local-6989586621680853968"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853968"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionTy"><span class="hs-identifier hs-type">CoercionTy</span></a></span><span> </span><span id="local-6989586621680853966"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853966"><span class="hs-identifier hs-var">co1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionTy"><span class="hs-identifier hs-type">CoercionTy</span></a></span><span> </span><span id="local-6989586621680853965"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853965"><span class="hs-identifier hs-var">co2</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680853964"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853964"><span class="hs-identifier hs-var">kco</span></a></span></span><span>
</span><span id="line-1038"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680853963"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853963"><span class="hs-identifier hs-var">c_subst</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UM CvSubstEnv
</span><a href="GHC.Core.Unify.html#getCvSubstEnv"><span class="hs-identifier hs-var">getCvSubstEnv</span></a></span><span>
</span><span id="line-1039"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853966"><span class="hs-identifier hs-var">co1</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1040"></span><span>           </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoVarCo"><span class="hs-identifier hs-type">CoVarCo</span></a></span><span> </span><span id="local-6989586621680853961"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853961"><span class="hs-identifier hs-var">cv</span></a></span></span><span>
</span><span id="line-1041"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMEnv -&gt; Bool
</span><a href="GHC.Core.Unify.html#um_unif"><span class="hs-identifier hs-var hs-var">um_unif</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853968"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1042"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853961"><span class="hs-identifier hs-var">cv</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; CvSubstEnv -&gt; Bool
forall a. OutTyVar -&gt; VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#elemVarEnv"><span class="hs-operator hs-var">`elemVarEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853963"><span class="hs-identifier hs-var">c_subst</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1043"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#BindMe"><span class="hs-identifier hs-var">BindMe</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; BindFlag
</span><a href="GHC.Core.Unify.html#tvBindFlag"><span class="hs-identifier hs-var">tvBindFlag</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853968"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853961"><span class="hs-identifier hs-var">cv</span></a></span><span>
</span><span id="line-1044"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; VarSet -&gt; UM ()
</span><a href="GHC.Core.Unify.html#checkRnEnv"><span class="hs-identifier hs-var">checkRnEnv</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853968"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfCo"><span class="hs-identifier hs-var">tyCoVarsOfCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853965"><span class="hs-identifier hs-var">co2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1045"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853956"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853956"><span class="hs-identifier hs-var">co_l</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853955"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853955"><span class="hs-identifier hs-var">co_r</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt;
Role -&gt; Coercion -&gt; (Coercion, Coercion, Coercion)
Role -&gt; Coercion -&gt; (Coercion, Coercion, Coercion)
</span><a href="GHC.Core.Coercion.html#decomposeFunCo"><span class="hs-identifier hs-var">decomposeFunCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853964"><span class="hs-identifier hs-var">kco</span></a></span><span>
</span><span id="line-1046"></span><span>                     </span><span class="hs-comment">-- Because the coercion is nominal, it should be safe to</span><span>
</span><span id="line-1047"></span><span>                     </span><span class="hs-comment">-- ignore the multiplicity coercion.</span><span>
</span><span id="line-1048"></span><span>                      </span><span class="hs-comment">-- cv :: t1 ~ t2</span><span>
</span><span id="line-1049"></span><span>                      </span><span class="hs-comment">-- co2 :: s1 ~ s2</span><span>
</span><span id="line-1050"></span><span>                      </span><span class="hs-comment">-- co_l :: t1 ~ s1</span><span>
</span><span id="line-1051"></span><span>                      </span><span class="hs-comment">-- co_r :: t2 ~ s2</span><span>
</span><span id="line-1052"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#extendCvEnv"><span class="hs-identifier hs-var">extendCvEnv</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853961"><span class="hs-identifier hs-var">cv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853956"><span class="hs-identifier hs-var">co_l</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkTransCo"><span class="hs-operator hs-var">`mkTransCo`</span></a></span><span>
</span><span id="line-1053"></span><span>                                     </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853965"><span class="hs-identifier hs-var">co2</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkTransCo"><span class="hs-operator hs-var">`mkTransCo`</span></a></span><span>
</span><span id="line-1054"></span><span>                                     </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkSymCo"><span class="hs-identifier hs-var">mkSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853955"><span class="hs-identifier hs-var">co_r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1055"></span><span>           </span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; UM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1056"></span><span>
</span><span id="line-1057"></span><span class="annot"><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UM ()
forall a. UM a
</span><a href="GHC.Core.Unify.html#surelyApart"><span class="hs-identifier hs-var">surelyApart</span></a></span><span>
</span><span id="line-1058"></span><span>
</span><span id="line-1059"></span><span class="annot"><a href="GHC.Core.Unify.html#unify_ty_app"><span class="hs-identifier hs-type">unify_ty_app</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-type">UMEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1060"></span><span id="unify_ty_app"><span class="annot"><span class="annottext">unify_ty_app :: UMEnv -&gt; Type -&gt; [Type] -&gt; Type -&gt; [Type] -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_ty_app"><span class="hs-identifier hs-var hs-var">unify_ty_app</span></a></span></span><span> </span><span id="local-6989586621680853951"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853951"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680853950"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853950"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621680853949"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853949"><span class="hs-identifier hs-var">ty1args</span></a></span></span><span> </span><span id="local-6989586621680853948"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853948"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span id="local-6989586621680853947"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853947"><span class="hs-identifier hs-var">ty2args</span></a></span></span><span>
</span><span id="line-1061"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853946"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853946"><span class="hs-identifier hs-var">ty1'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853945"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853945"><span class="hs-identifier hs-var">ty1a</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (Type, Type)
Type -&gt; Maybe (Type, Type)
</span><a href="GHC.Core.Type.html#repSplitAppTy_maybe"><span class="hs-identifier hs-var">repSplitAppTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853950"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1062"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853943"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853943"><span class="hs-identifier hs-var">ty2'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853942"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853942"><span class="hs-identifier hs-var">ty2a</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (Type, Type)
Type -&gt; Maybe (Type, Type)
</span><a href="GHC.Core.Type.html#repSplitAppTy_maybe"><span class="hs-identifier hs-var">repSplitAppTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853948"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1063"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Type -&gt; [Type] -&gt; Type -&gt; [Type] -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_ty_app"><span class="hs-identifier hs-var">unify_ty_app</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853951"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853946"><span class="hs-identifier hs-var">ty1'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853945"><span class="hs-identifier hs-var">ty1a</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; [Type] -&gt; [Type]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853949"><span class="hs-identifier hs-var">ty1args</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853943"><span class="hs-identifier hs-var">ty2'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853942"><span class="hs-identifier hs-var">ty2a</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; [Type] -&gt; [Type]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853947"><span class="hs-identifier hs-var">ty2args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1064"></span><span>
</span><span id="line-1065"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1066"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680853940"><span class="annot"><span class="annottext">ki1 :: Type
</span><a href="#local-6989586621680853940"><span class="hs-identifier hs-var hs-var">ki1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Type
Type -&gt; Type
</span><a href="GHC.Core.Type.html#typeKind"><span class="hs-identifier hs-var">typeKind</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853950"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1067"></span><span>             </span><span id="local-6989586621680853938"><span class="annot"><span class="annottext">ki2 :: Type
</span><a href="#local-6989586621680853938"><span class="hs-identifier hs-var hs-var">ki2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Type
Type -&gt; Type
</span><a href="GHC.Core.Type.html#typeKind"><span class="hs-identifier hs-var">typeKind</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853948"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1068"></span><span>           </span><span class="hs-comment">-- See Note [Kind coercions in Unify]</span><span>
</span><span id="line-1069"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Type -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span>  </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853951"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853940"><span class="hs-identifier hs-var">ki1</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853938"><span class="hs-identifier hs-var">ki2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.html#liftedTypeKind"><span class="hs-identifier hs-var">liftedTypeKind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1070"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Type -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span>  </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853951"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853950"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853948"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853938"><span class="hs-identifier hs-var">ki2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1071"></span><span>                 </span><span class="hs-comment">-- Very important: 'ki2' not 'ki1'</span><span>
</span><span id="line-1072"></span><span>                 </span><span class="hs-comment">-- See Note [Matching in the presence of casts (2)]</span><span>
</span><span id="line-1073"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; [Type] -&gt; [Type] -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_tys"><span class="hs-identifier hs-var">unify_tys</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853951"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853949"><span class="hs-identifier hs-var">ty1args</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853947"><span class="hs-identifier hs-var">ty2args</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1074"></span><span>
</span><span id="line-1075"></span><span class="annot"><a href="GHC.Core.Unify.html#unify_tys"><span class="hs-identifier hs-type">unify_tys</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-type">UMEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1076"></span><span id="unify_tys"><span class="annot"><span class="annottext">unify_tys :: UMEnv -&gt; [Type] -&gt; [Type] -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_tys"><span class="hs-identifier hs-var hs-var">unify_tys</span></a></span></span><span> </span><span id="local-6989586621680853937"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853937"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680853936"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853936"><span class="hs-identifier hs-var">orig_xs</span></a></span></span><span> </span><span id="local-6989586621680853935"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853935"><span class="hs-identifier hs-var">orig_ys</span></a></span></span><span>
</span><span id="line-1077"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; UM ()
</span><a href="#local-6989586621680853934"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853936"><span class="hs-identifier hs-var">orig_xs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853935"><span class="hs-identifier hs-var">orig_ys</span></a></span><span>
</span><span id="line-1078"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1079"></span><span>    </span><span id="local-6989586621680853934"><span class="annot"><span class="annottext">go :: [Type] -&gt; [Type] -&gt; UM ()
</span><a href="#local-6989586621680853934"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; UM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1080"></span><span>    </span><span class="annot"><a href="#local-6989586621680853934"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853930"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853930"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680853929"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853929"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853928"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853928"><span class="hs-identifier hs-var">y</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680853927"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853927"><span class="hs-identifier hs-var">ys</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1081"></span><span>      </span><span class="hs-comment">-- See Note [Kind coercions in Unify]</span><span>
</span><span id="line-1082"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Type -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853937"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853930"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853928"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Coercion) -&gt; Type -&gt; Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Type
Type -&gt; Type
</span><a href="GHC.Core.Type.html#typeKind"><span class="hs-identifier hs-var">typeKind</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853928"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1083"></span><span>                 </span><span class="hs-comment">-- Very important: 'y' not 'x'</span><span>
</span><span id="line-1084"></span><span>                 </span><span class="hs-comment">-- See Note [Matching in the presence of casts (2)]</span><span>
</span><span id="line-1085"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; UM ()
</span><a href="#local-6989586621680853934"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853929"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853927"><span class="hs-identifier hs-var">ys</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1086"></span><span>    </span><span class="annot"><a href="#local-6989586621680853934"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UM ()
forall a. UM a
</span><a href="GHC.Core.Unify.html#surelyApart"><span class="hs-identifier hs-var">surelyApart</span></a></span><span>
</span><span id="line-1087"></span><span>      </span><span class="hs-comment">-- Possibly different saturations of a polykinded tycon</span><span>
</span><span id="line-1088"></span><span>      </span><span class="hs-comment">-- See Note [Polykinded tycon applications]</span><span>
</span><span id="line-1089"></span><span>
</span><span id="line-1090"></span><span class="hs-comment">---------------------------------</span><span>
</span><span id="line-1091"></span><span class="annot"><a href="GHC.Core.Unify.html#uVar"><span class="hs-identifier hs-type">uVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-type">UMEnv</span></a></span><span>
</span><span id="line-1092"></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#InTyVar"><span class="hs-identifier hs-type">InTyVar</span></a></span><span>         </span><span class="hs-comment">-- Variable to be unified</span><span>
</span><span id="line-1093"></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>            </span><span class="hs-comment">-- with this Type</span><span>
</span><span id="line-1094"></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>        </span><span class="hs-comment">-- :: kind tv ~N kind ty</span><span>
</span><span id="line-1095"></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1096"></span><span>
</span><span id="line-1097"></span><span id="uVar"><span class="annot"><span class="annottext">uVar :: UMEnv -&gt; OutTyVar -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#uVar"><span class="hs-identifier hs-var hs-var">uVar</span></a></span></span><span> </span><span id="local-6989586621680853925"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853925"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680853924"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853924"><span class="hs-identifier hs-var">tv1</span></a></span></span><span> </span><span id="local-6989586621680853923"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853923"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680853922"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853922"><span class="hs-identifier hs-var">kco</span></a></span></span><span>
</span><span id="line-1098"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- Apply the ambient renaming</span><span>
</span><span id="line-1099"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680853921"><span class="annot"><span class="annottext">tv1' :: OutTyVar
</span><a href="#local-6989586621680853921"><span class="hs-identifier hs-var hs-var">tv1'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; OutTyVar
</span><a href="GHC.Core.Unify.html#umRnOccL"><span class="hs-identifier hs-var">umRnOccL</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853925"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853924"><span class="hs-identifier hs-var">tv1</span></a></span><span>
</span><span id="line-1100"></span><span>
</span><span id="line-1101"></span><span>        </span><span class="hs-comment">-- Check to see whether tv1 is refined by the substitution</span><span>
</span><span id="line-1102"></span><span>      </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680853919"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680853919"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UM TvSubstEnv
</span><a href="GHC.Core.Unify.html#getTvSubstEnv"><span class="hs-identifier hs-var">getTvSubstEnv</span></a></span><span>
</span><span id="line-1103"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv -&gt; OutTyVar -&gt; Maybe Type
forall a. VarEnv a -&gt; OutTyVar -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680853919"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853921"><span class="hs-identifier hs-var">tv1'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1104"></span><span>          </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680853918"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853918"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Bool
</span><a href="GHC.Core.Unify.html#um_unif"><span class="hs-identifier hs-var hs-var">um_unif</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853925"><span class="hs-identifier hs-var">env</span></a></span><span>                </span><span class="hs-comment">-- Unifying, so call</span><span>
</span><span id="line-1105"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Type -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#unify_ty"><span class="hs-identifier hs-var">unify_ty</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853925"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853918"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853923"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853922"><span class="hs-identifier hs-var">kco</span></a></span><span>   </span><span class="hs-comment">-- back into unify</span><span>
</span><span id="line-1106"></span><span>                   </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1107"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-comment">-- Matching, we don't want to just recur here.</span><span>
</span><span id="line-1108"></span><span>                      </span><span class="hs-comment">-- this is because the range of the subst is the target</span><span>
</span><span id="line-1109"></span><span>                      </span><span class="hs-comment">-- type, not the template type. So, just check for</span><span>
</span><span id="line-1110"></span><span>                      </span><span class="hs-comment">-- normal type equality.</span><span>
</span><span id="line-1111"></span><span>                      </span><span class="annot"><span class="annottext">Bool -&gt; UM ()
forall (f :: * -&gt; *). Alternative f =&gt; Bool -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#guard"><span class="hs-identifier hs-var">guard</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853918"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Coercion -&gt; Type
</span><a href="GHC.Core.Type.html#mkCastTy"><span class="hs-operator hs-var">`mkCastTy`</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853922"><span class="hs-identifier hs-var">kco</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Bool
</span><a href="GHC.Core.Type.html#eqType"><span class="hs-operator hs-var">`eqType`</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853923"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1112"></span><span>          </span><span class="annot"><span class="annottext">Maybe Type
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; Type -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#uUnrefined"><span class="hs-identifier hs-var">uUnrefined</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853925"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853921"><span class="hs-identifier hs-var">tv1'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853923"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853923"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853922"><span class="hs-identifier hs-var">kco</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-comment">-- No, continue</span><span>
</span><span id="line-1113"></span><span>
</span><span id="line-1114"></span><span class="annot"><a href="GHC.Core.Unify.html#uUnrefined"><span class="hs-identifier hs-type">uUnrefined</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-type">UMEnv</span></a></span><span>
</span><span id="line-1115"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutTyVar"><span class="hs-identifier hs-type">OutTyVar</span></a></span><span>          </span><span class="hs-comment">-- variable to be unified</span><span>
</span><span id="line-1116"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>              </span><span class="hs-comment">-- with this Type</span><span>
</span><span id="line-1117"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>              </span><span class="hs-comment">-- (version w/ expanded synonyms)</span><span>
</span><span id="line-1118"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>          </span><span class="hs-comment">-- :: kind tv ~N kind ty</span><span>
</span><span id="line-1119"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1120"></span><span>
</span><span id="line-1121"></span><span class="hs-comment">-- We know that tv1 isn't refined</span><span>
</span><span id="line-1122"></span><span>
</span><span id="line-1123"></span><span id="uUnrefined"><span class="annot"><span class="annottext">uUnrefined :: UMEnv -&gt; OutTyVar -&gt; Type -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#uUnrefined"><span class="hs-identifier hs-var hs-var">uUnrefined</span></a></span></span><span> </span><span id="local-6989586621680853914"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853914"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680853913"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853913"><span class="hs-identifier hs-var">tv1'</span></a></span></span><span> </span><span id="local-6989586621680853912"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853912"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span id="local-6989586621680853911"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853911"><span class="hs-identifier hs-var">ty2'</span></a></span></span><span> </span><span id="local-6989586621680853910"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853910"><span class="hs-identifier hs-var">kco</span></a></span></span><span>
</span><span id="line-1124"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680853909"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853909"><span class="hs-identifier hs-var">ty2''</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe Type
</span><a href="GHC.Core.Type.html#coreView"><span class="hs-identifier hs-var">coreView</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853911"><span class="hs-identifier hs-var">ty2'</span></a></span><span>
</span><span id="line-1125"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; Type -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#uUnrefined"><span class="hs-identifier hs-var">uUnrefined</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853914"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853913"><span class="hs-identifier hs-var">tv1'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853912"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853909"><span class="hs-identifier hs-var">ty2''</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853910"><span class="hs-identifier hs-var">kco</span></a></span><span>    </span><span class="hs-comment">-- Unwrap synonyms</span><span>
</span><span id="line-1126"></span><span>                </span><span class="hs-comment">-- This is essential, in case we have</span><span>
</span><span id="line-1127"></span><span>                </span><span class="hs-comment">--      type Foo a = a</span><span>
</span><span id="line-1128"></span><span>                </span><span class="hs-comment">-- and then unify a ~ Foo a</span><span>
</span><span id="line-1129"></span><span>
</span><span id="line-1130"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621680853907"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853907"><span class="hs-identifier hs-var">tv2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853911"><span class="hs-identifier hs-var">ty2'</span></a></span><span>
</span><span id="line-1131"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680853906"><span class="annot"><span class="annottext">tv2' :: OutTyVar
</span><a href="#local-6989586621680853906"><span class="hs-identifier hs-var hs-var">tv2'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; OutTyVar
</span><a href="GHC.Core.Unify.html#umRnOccR"><span class="hs-identifier hs-var">umRnOccR</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853914"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853907"><span class="hs-identifier hs-var">tv2</span></a></span><span>
</span><span id="line-1132"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; UM () -&gt; UM ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853913"><span class="hs-identifier hs-var">tv1'</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; OutTyVar -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853906"><span class="hs-identifier hs-var">tv2'</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Bool
</span><a href="GHC.Core.Unify.html#um_unif"><span class="hs-identifier hs-var hs-var">um_unif</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853914"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(UM () -&gt; UM ()) -&gt; UM () -&gt; UM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1133"></span><span>           </span><span class="hs-comment">-- If we are unifying a ~ a, just return immediately</span><span>
</span><span id="line-1134"></span><span>           </span><span class="hs-comment">-- Do not extend the substitution</span><span>
</span><span id="line-1135"></span><span>           </span><span class="hs-comment">-- See Note [Self-substitution when matching]</span><span>
</span><span id="line-1136"></span><span>
</span><span id="line-1137"></span><span>          </span><span class="hs-comment">-- Check to see whether tv2 is refined</span><span>
</span><span id="line-1138"></span><span>       </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680853904"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680853904"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UM TvSubstEnv
</span><a href="GHC.Core.Unify.html#getTvSubstEnv"><span class="hs-identifier hs-var">getTvSubstEnv</span></a></span><span>
</span><span id="line-1139"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; OutTyVar -&gt; Maybe Type
forall a. VarEnv a -&gt; OutTyVar -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680853904"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853907"><span class="hs-identifier hs-var">tv2</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1140"></span><span>         </span><span class="hs-special">{</span><span>  </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680853903"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853903"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Bool
</span><a href="GHC.Core.Unify.html#um_unif"><span class="hs-identifier hs-var hs-var">um_unif</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853914"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; Type -&gt; Type -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#uUnrefined"><span class="hs-identifier hs-var">uUnrefined</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853914"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853913"><span class="hs-identifier hs-var">tv1'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853903"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853903"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853910"><span class="hs-identifier hs-var">kco</span></a></span><span>
</span><span id="line-1141"></span><span>         </span><span class="hs-special">;</span><span>  </span><span class="annot"><span class="annottext">Maybe Type
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1142"></span><span>
</span><span id="line-1143"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span>   </span><span class="hs-comment">-- So both are unrefined</span><span>
</span><span id="line-1144"></span><span>           </span><span class="hs-comment">-- Bind one or the other, depending on which is bindable</span><span>
</span><span id="line-1145"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680853902"><span class="annot"><span class="annottext">b1 :: BindFlag
</span><a href="#local-6989586621680853902"><span class="hs-identifier hs-var hs-var">b1</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; BindFlag
</span><a href="GHC.Core.Unify.html#tvBindFlag"><span class="hs-identifier hs-var">tvBindFlag</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853914"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853913"><span class="hs-identifier hs-var">tv1'</span></a></span><span>
</span><span id="line-1146"></span><span>             </span><span id="local-6989586621680853901"><span class="annot"><span class="annottext">b2 :: BindFlag
</span><a href="#local-6989586621680853901"><span class="hs-identifier hs-var hs-var">b2</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; BindFlag
</span><a href="GHC.Core.Unify.html#tvBindFlag"><span class="hs-identifier hs-var">tvBindFlag</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853914"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853906"><span class="hs-identifier hs-var">tv2'</span></a></span><span>
</span><span id="line-1147"></span><span>             </span><span id="local-6989586621680853900"><span class="annot"><span class="annottext">ty1 :: Type
</span><a href="#local-6989586621680853900"><span class="hs-identifier hs-var hs-var">ty1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853913"><span class="hs-identifier hs-var">tv1'</span></a></span><span>
</span><span id="line-1148"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BindFlag
</span><a href="#local-6989586621680853902"><span class="hs-identifier hs-var">b1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">BindFlag
</span><a href="#local-6989586621680853901"><span class="hs-identifier hs-var">b2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1149"></span><span>           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#BindMe"><span class="hs-identifier hs-var">BindMe</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">BindFlag
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; Type -&gt; UM ()
</span><a href="GHC.Core.Unify.html#bindTv"><span class="hs-identifier hs-var">bindTv</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853914"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853913"><span class="hs-identifier hs-var">tv1'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853912"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Coercion -&gt; Type
</span><a href="GHC.Core.Type.html#mkCastTy"><span class="hs-operator hs-var">`mkCastTy`</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkSymCo"><span class="hs-identifier hs-var">mkSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853910"><span class="hs-identifier hs-var">kco</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1150"></span><span>           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BindFlag
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#BindMe"><span class="hs-identifier hs-var">BindMe</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Bool
</span><a href="GHC.Core.Unify.html#um_unif"><span class="hs-identifier hs-var hs-var">um_unif</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853914"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-1151"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; Type -&gt; UM ()
</span><a href="GHC.Core.Unify.html#bindTv"><span class="hs-identifier hs-var">bindTv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMEnv -&gt; UMEnv
</span><a href="GHC.Core.Unify.html#umSwapRn"><span class="hs-identifier hs-var">umSwapRn</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853914"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853907"><span class="hs-identifier hs-var">tv2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853900"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Coercion -&gt; Type
</span><a href="GHC.Core.Type.html#mkCastTy"><span class="hs-operator hs-var">`mkCastTy`</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853910"><span class="hs-identifier hs-var">kco</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1152"></span><span>
</span><span id="line-1153"></span><span>           </span><span class="annot"><span class="annottext">(BindFlag, BindFlag)
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853913"><span class="hs-identifier hs-var">tv1'</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; OutTyVar -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853906"><span class="hs-identifier hs-var">tv2'</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; UM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1154"></span><span>             </span><span class="hs-comment">-- How could this happen? If we're only matching and if</span><span>
</span><span id="line-1155"></span><span>             </span><span class="hs-comment">-- we're comparing forall-bound variables.</span><span>
</span><span id="line-1156"></span><span>
</span><span id="line-1157"></span><span>           </span><span class="annot"><span class="annottext">(BindFlag, BindFlag)
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UM ()
</span><a href="GHC.Core.Unify.html#maybeApart"><span class="hs-identifier hs-var">maybeApart</span></a></span><span> </span><span class="hs-comment">-- See Note [Unification with skolems]</span><span>
</span><span id="line-1158"></span><span>  </span><span class="hs-special">}</span><span class="hs-special">}</span><span class="hs-special">}</span><span class="hs-special">}</span><span>
</span><span id="line-1159"></span><span>
</span><span id="line-1160"></span><span class="annot"><a href="GHC.Core.Unify.html#uUnrefined"><span class="hs-identifier hs-var">uUnrefined</span></a></span><span> </span><span id="local-6989586621680853898"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853898"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680853897"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853897"><span class="hs-identifier hs-var">tv1'</span></a></span></span><span> </span><span id="local-6989586621680853896"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853896"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680853895"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853895"><span class="hs-identifier hs-var">kco</span></a></span></span><span> </span><span class="hs-comment">-- ty2 is not a type variable</span><span>
</span><span id="line-1161"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; BindFlag
</span><a href="GHC.Core.Unify.html#tvBindFlag"><span class="hs-identifier hs-var">tvBindFlag</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853898"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853897"><span class="hs-identifier hs-var">tv1'</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1162"></span><span>      </span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#Skolem"><span class="hs-identifier hs-var">Skolem</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UM ()
</span><a href="GHC.Core.Unify.html#maybeApart"><span class="hs-identifier hs-var">maybeApart</span></a></span><span>  </span><span class="hs-comment">-- See Note [Unification with skolems]</span><span>
</span><span id="line-1163"></span><span>      </span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#BindMe"><span class="hs-identifier hs-var">BindMe</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; Type -&gt; UM ()
</span><a href="GHC.Core.Unify.html#bindTv"><span class="hs-identifier hs-var">bindTv</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853898"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853897"><span class="hs-identifier hs-var">tv1'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853896"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Coercion -&gt; Type
</span><a href="GHC.Core.Type.html#mkCastTy"><span class="hs-operator hs-var">`mkCastTy`</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkSymCo"><span class="hs-identifier hs-var">mkSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853895"><span class="hs-identifier hs-var">kco</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1164"></span><span>
</span><span id="line-1165"></span><span class="annot"><a href="GHC.Core.Unify.html#bindTv"><span class="hs-identifier hs-type">bindTv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-type">UMEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutTyVar"><span class="hs-identifier hs-type">OutTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1166"></span><span class="hs-comment">-- OK, so we want to extend the substitution with tv := ty</span><span>
</span><span id="line-1167"></span><span class="hs-comment">-- But first, we must do a couple of checks</span><span>
</span><span id="line-1168"></span><span id="bindTv"><span class="annot"><span class="annottext">bindTv :: UMEnv -&gt; OutTyVar -&gt; Type -&gt; UM ()
</span><a href="GHC.Core.Unify.html#bindTv"><span class="hs-identifier hs-var hs-var">bindTv</span></a></span></span><span> </span><span id="local-6989586621680853894"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853894"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680853893"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853893"><span class="hs-identifier hs-var">tv1</span></a></span></span><span> </span><span id="local-6989586621680853892"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853892"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1169"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680853891"><span class="annot"><span class="annottext">free_tvs2 :: VarSet
</span><a href="#local-6989586621680853891"><span class="hs-identifier hs-var hs-var">free_tvs2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853892"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1170"></span><span>
</span><span id="line-1171"></span><span>        </span><span class="hs-comment">-- Make sure tys mentions no local variables</span><span>
</span><span id="line-1172"></span><span>        </span><span class="hs-comment">-- E.g.  (forall a. b) ~ (forall a. [a])</span><span>
</span><span id="line-1173"></span><span>        </span><span class="hs-comment">-- We should not unify b := [a]!</span><span>
</span><span id="line-1174"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; VarSet -&gt; UM ()
</span><a href="GHC.Core.Unify.html#checkRnEnv"><span class="hs-identifier hs-var">checkRnEnv</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853894"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680853891"><span class="hs-identifier hs-var">free_tvs2</span></a></span><span>
</span><span id="line-1175"></span><span>
</span><span id="line-1176"></span><span>        </span><span class="hs-comment">-- Occurs check, see Note [Fine-grained unification]</span><span>
</span><span id="line-1177"></span><span>        </span><span class="hs-comment">-- Make sure you include 'kco' (which ty2 does) #14846</span><span>
</span><span id="line-1178"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680853890"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680853890"><span class="hs-identifier hs-var">occurs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; VarSet -&gt; UM Bool
</span><a href="GHC.Core.Unify.html#occursCheck"><span class="hs-identifier hs-var">occursCheck</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853894"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853893"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680853891"><span class="hs-identifier hs-var">free_tvs2</span></a></span><span>
</span><span id="line-1179"></span><span>
</span><span id="line-1180"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680853890"><span class="hs-identifier hs-var">occurs</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">UM ()
</span><a href="GHC.Core.Unify.html#maybeApart"><span class="hs-identifier hs-var">maybeApart</span></a></span><span>
</span><span id="line-1181"></span><span>                    </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; Type -&gt; UM ()
</span><a href="GHC.Core.Unify.html#extendTvEnv"><span class="hs-identifier hs-var">extendTvEnv</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853893"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853892"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1182"></span><span>
</span><span id="line-1183"></span><span class="annot"><a href="GHC.Core.Unify.html#occursCheck"><span class="hs-identifier hs-type">occursCheck</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-type">UMEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1184"></span><span id="occursCheck"><span class="annot"><span class="annottext">occursCheck :: UMEnv -&gt; OutTyVar -&gt; VarSet -&gt; UM Bool
</span><a href="GHC.Core.Unify.html#occursCheck"><span class="hs-identifier hs-var hs-var">occursCheck</span></a></span></span><span> </span><span id="local-6989586621680853887"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853887"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680853886"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853886"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621680853885"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680853885"><span class="hs-identifier hs-var">free_tvs</span></a></span></span><span>
</span><span id="line-1185"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; Bool
</span><a href="GHC.Core.Unify.html#um_unif"><span class="hs-identifier hs-var hs-var">um_unif</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853887"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-1186"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680853884"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680853884"><span class="hs-identifier hs-var">tsubst</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UM TvSubstEnv
</span><a href="GHC.Core.Unify.html#getTvSubstEnv"><span class="hs-identifier hs-var">getTvSubstEnv</span></a></span><span>
</span><span id="line-1187"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; UM Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853886"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Core.Unify.html#niSubstTvSet"><span class="hs-identifier hs-var">niSubstTvSet</span></a></span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680853884"><span class="hs-identifier hs-var">tsubst</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680853885"><span class="hs-identifier hs-var">free_tvs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1188"></span><span>
</span><span id="line-1189"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-comment">-- Matching; no occurs check</span><span>
</span><span id="line-1190"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; UM Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>   </span><span class="hs-comment">-- See Note [Self-substitution when matching]</span><span>
</span><span id="line-1191"></span><span>
</span><span id="line-1192"></span><span class="hs-comment">{-
%************************************************************************
%*                                                                      *
                Binding decisions
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-1199"></span><span>
</span><span id="line-1200"></span><span class="hs-keyword">data</span><span> </span><span id="BindFlag"><span class="annot"><a href="GHC.Core.Unify.html#BindFlag"><span class="hs-identifier hs-var">BindFlag</span></a></span></span><span>
</span><span id="line-1201"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="BindMe"><span class="annot"><a href="GHC.Core.Unify.html#BindMe"><span class="hs-identifier hs-var">BindMe</span></a></span></span><span>      </span><span class="hs-comment">-- A regular type variable</span><span>
</span><span id="line-1202"></span><span>
</span><span id="line-1203"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="Skolem"><span class="annot"><a href="GHC.Core.Unify.html#Skolem"><span class="hs-identifier hs-var">Skolem</span></a></span></span><span>      </span><span class="hs-comment">-- This type variable is a skolem constant</span><span>
</span><span id="line-1204"></span><span>                </span><span class="hs-comment">-- Don't bind it; it only matches itself</span><span>
</span><span id="line-1205"></span><span>  </span><span class="hs-keyword">deriving</span><span> </span><span id="local-6989586621680853880"><span id="local-6989586621680853882"><span class="annot"><span class="annottext">BindFlag -&gt; BindFlag -&gt; Bool
(BindFlag -&gt; BindFlag -&gt; Bool)
-&gt; (BindFlag -&gt; BindFlag -&gt; Bool) -&gt; Eq BindFlag
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: BindFlag -&gt; BindFlag -&gt; Bool
$c/= :: BindFlag -&gt; BindFlag -&gt; Bool
== :: BindFlag -&gt; BindFlag -&gt; Bool
$c== :: BindFlag -&gt; BindFlag -&gt; Bool
</span><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></span></span></span><span>
</span><span id="line-1206"></span><span>
</span><span id="line-1207"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                Unification monad
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-1214"></span><span>
</span><span id="line-1215"></span><span class="hs-comment">{- Note [The one-shot state monad trick]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Many places in GHC use a state monad, and we really want those
functions to be eta-expanded (#18202).  Consider

    newtype M a = MkM (State -&gt; (State, a))

    instance Monad M where
       mf &gt;&gt;= k = MkM (\s -&gt; case mf  of MkM f  -&gt;
                             case f s of (s',r) -&gt;
                             case k r of MkM g  -&gt;
                             g s')

    foo :: Int -&gt; M Int
    foo x = g y &gt;&gt;= \r -&gt; h r
      where
        y = expensive x

In general, you might say (map (foo 4) xs), and expect (expensive 4)
to be evaluated only once.  So foo should have arity 1 (not 2).
But that's rare, and if you /aren't/ re-using (M a) values it's much
more efficient to make foo have arity 2.

See https://www.joachim-breitner.de/blog/763-Faster_Winter_5__Eta-Expanding_ReaderT

So here is the trick.  Define

    data M a = MkM' (State -&gt; (State, a))
    pattern MkM f &lt;- MkM' f
      where
        MkM f = MkM' (oneShot f)

The patten synonm means that whenever we write (MkM f), we'll
actually get (MkM' (oneShot f)), so we'll pin a one-shot flag
on f's lambda-binder. Now look at foo:

  foo = \x. g (expensive x) &gt;&gt;= \r -&gt; h r
      = \x. let mf = g (expensive x)
                k  = \r -&gt; h r
            in MkM' (oneShot (\s -&gt; case mf  of MkM' f  -&gt;
                                    case f s of (s',r) -&gt;
                                    case k r of MkM' g  -&gt;
                                    g s'))
      -- The MkM' are just newtype casts nt_co
      = \x. let mf = g (expensive x)
                k  = \r -&gt; h r
            in (\s{os}. case (mf |&gt; nt_co) s of (s',r) -&gt;
                        (k r) |&gt; nt_co s')
               |&gt; sym nt_co

      -- Float into that \s{os}
      = \x. (\s{os}. case (g (expensive x) |&gt; nt_co) s of (s',r) -&gt;
                     h r |&gt; nt_co s')
            |&gt; sym nt_co

and voila!  In summary:

* It's a very simple, two-line change

* It eta-expands all uses of the monad, automatically

* It is very similar to the built-in &quot;state hack&quot; (see
  GHC.Core.Opt.Arity Note [The state-transformer hack]) but the trick
  described here is applicable on a monad-by-monad basis under
  programmer control.

* Beware: itt changes the behaviour of
     map (foo 3) xs
  ToDo: explain what to do if you want to do this
-}</span><span>
</span><span id="line-1285"></span><span>
</span><span id="line-1286"></span><span class="hs-keyword">data</span><span> </span><span id="UMEnv"><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-var">UMEnv</span></a></span></span><span>
</span><span id="line-1287"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="UMEnv"><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-var">UMEnv</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="um_unif"><span class="annot"><span class="annottext">UMEnv -&gt; Bool
</span><a href="GHC.Core.Unify.html#um_unif"><span class="hs-identifier hs-var hs-var">um_unif</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#AmIUnifying"><span class="hs-identifier hs-type">AmIUnifying</span></a></span><span>
</span><span id="line-1288"></span><span>
</span><span id="line-1289"></span><span>          </span><span class="hs-special">,</span><span> </span><span id="um_inj_tf"><span class="annot"><span class="annottext">UMEnv -&gt; Bool
</span><a href="GHC.Core.Unify.html#um_inj_tf"><span class="hs-identifier hs-var hs-var">um_inj_tf</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1290"></span><span>            </span><span class="hs-comment">-- Checking for injectivity?</span><span>
</span><span id="line-1291"></span><span>            </span><span class="hs-comment">-- See (end of) Note [Specification of unification]</span><span>
</span><span id="line-1292"></span><span>
</span><span id="line-1293"></span><span>          </span><span class="hs-special">,</span><span> </span><span id="um_rn_env"><span class="annot"><span class="annottext">UMEnv -&gt; RnEnv2
</span><a href="GHC.Core.Unify.html#um_rn_env"><span class="hs-identifier hs-var hs-var">um_rn_env</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#RnEnv2"><span class="hs-identifier hs-type">RnEnv2</span></a></span><span>
</span><span id="line-1294"></span><span>            </span><span class="hs-comment">-- Renaming InTyVars to OutTyVars; this eliminates</span><span>
</span><span id="line-1295"></span><span>            </span><span class="hs-comment">-- shadowing, and lines up matching foralls on the left</span><span>
</span><span id="line-1296"></span><span>            </span><span class="hs-comment">-- and right</span><span>
</span><span id="line-1297"></span><span>
</span><span id="line-1298"></span><span>          </span><span class="hs-special">,</span><span> </span><span id="um_skols"><span class="annot"><span class="annottext">UMEnv -&gt; VarSet
</span><a href="GHC.Core.Unify.html#um_skols"><span class="hs-identifier hs-var hs-var">um_skols</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyVarSet"><span class="hs-identifier hs-type">TyVarSet</span></a></span><span>
</span><span id="line-1299"></span><span>            </span><span class="hs-comment">-- OutTyVars bound by a forall in this unification;</span><span>
</span><span id="line-1300"></span><span>            </span><span class="hs-comment">-- Do not bind these in the substitution!</span><span>
</span><span id="line-1301"></span><span>            </span><span class="hs-comment">-- See the function tvBindFlag</span><span>
</span><span id="line-1302"></span><span>
</span><span id="line-1303"></span><span>          </span><span class="hs-special">,</span><span> </span><span id="um_bind_fun"><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; BindFlag
</span><a href="GHC.Core.Unify.html#um_bind_fun"><span class="hs-identifier hs-var hs-var">um_bind_fun</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#BindFlag"><span class="hs-identifier hs-type">BindFlag</span></a></span><span>
</span><span id="line-1304"></span><span>            </span><span class="hs-comment">-- User-supplied BindFlag function,</span><span>
</span><span id="line-1305"></span><span>            </span><span class="hs-comment">-- for variables not in um_skols</span><span>
</span><span id="line-1306"></span><span>          </span><span class="hs-special">}</span><span>
</span><span id="line-1307"></span><span>
</span><span id="line-1308"></span><span class="hs-keyword">data</span><span> </span><span id="UMState"><span class="annot"><a href="GHC.Core.Unify.html#UMState"><span class="hs-identifier hs-var">UMState</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="UMState"><span class="annot"><a href="GHC.Core.Unify.html#UMState"><span class="hs-identifier hs-var">UMState</span></a></span></span><span>
</span><span id="line-1309"></span><span>                   </span><span class="hs-special">{</span><span> </span><span id="um_tv_env"><span class="annot"><span class="annottext">UMState -&gt; TvSubstEnv
</span><a href="GHC.Core.Unify.html#um_tv_env"><span class="hs-identifier hs-var hs-var">um_tv_env</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span>
</span><span id="line-1310"></span><span>                   </span><span class="hs-special">,</span><span> </span><span id="um_cv_env"><span class="annot"><span class="annottext">UMState -&gt; CvSubstEnv
</span><a href="GHC.Core.Unify.html#um_cv_env"><span class="hs-identifier hs-var hs-var">um_cv_env</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1311"></span><span>
</span><span id="line-1312"></span><span class="hs-keyword">newtype</span><span> </span><span id="UM"><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-var">UM</span></a></span></span><span> </span><span id="local-6989586621680854501"><span class="annot"><a href="#local-6989586621680854501"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-1313"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="UM%27"><span class="annot"><a href="GHC.Core.Unify.html#UM%27"><span class="hs-identifier hs-var">UM'</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="unUM"><span class="annot"><span class="annottext">forall a. UM a -&gt; UMState -&gt; UnifyResultM (UMState, a)
</span><a href="GHC.Core.Unify.html#unUM"><span class="hs-identifier hs-var hs-var">unUM</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UMState"><span class="hs-identifier hs-type">UMState</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UnifyResultM"><span class="hs-identifier hs-type">UnifyResultM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Unify.html#UMState"><span class="hs-identifier hs-type">UMState</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621680854501"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1314"></span><span>    </span><span class="hs-comment">-- See Note [The one-shot state monad trick]</span><span>
</span><span id="line-1315"></span><span>  </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853868"><span id="local-6989586621680853871"><span class="annot"><span class="annottext">(forall a b. (a -&gt; b) -&gt; UM a -&gt; UM b)
-&gt; (forall a b. a -&gt; UM b -&gt; UM a) -&gt; Functor UM
forall a b. a -&gt; UM b -&gt; UM a
forall a b. (a -&gt; b) -&gt; UM a -&gt; UM b
forall (f :: * -&gt; *).
(forall a b. (a -&gt; b) -&gt; f a -&gt; f b)
-&gt; (forall a b. a -&gt; f b -&gt; f a) -&gt; Functor f
&lt;$ :: forall a b. a -&gt; UM b -&gt; UM a
$c&lt;$ :: forall a b. a -&gt; UM b -&gt; UM a
fmap :: forall a b. (a -&gt; b) -&gt; UM a -&gt; UM b
$cfmap :: forall a b. (a -&gt; b) -&gt; UM a -&gt; UM b
</span><a href="../../base/src/GHC.Base.html#Functor"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Functor</span></a></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-1316"></span><span>
</span><span id="line-1317"></span><span id="local-6989586621680854499"><span class="hs-keyword">pattern</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Unify.html#UMState"><span class="hs-identifier hs-type">UMState</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UnifyResultM"><span class="hs-identifier hs-type">UnifyResultM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Unify.html#UMState"><span class="hs-identifier hs-type">UMState</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621680854499"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680854499"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-1318"></span><span class="hs-comment">-- See Note [The one-shot state monad trick]</span><span>
</span><span id="line-1319"></span><span class="hs-keyword">pattern</span><span> </span><span id="%24mUM"><span id="%24bUM"><span id="UM"><span class="annot"><span class="annottext">$mUM :: forall {r} {a}.
UM a
-&gt; ((UMState -&gt; UnifyResultM (UMState, a)) -&gt; r)
-&gt; (Void# -&gt; r)
-&gt; r
$bUM :: forall a. (UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
</span><a href="GHC.Core.Unify.html#%24mUM"><span class="hs-identifier hs-var hs-var hs-var hs-var">UM</span></a></span></span></span></span><span> </span><span class="annot"><a href="#local-6989586621680853863"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM%27"><span class="hs-identifier hs-type">UM'</span></a></span><span> </span><span id="local-6989586621680853863"><span class="annot"><a href="#local-6989586621680853863"><span class="hs-identifier hs-var">m</span></a></span></span><span>
</span><span id="line-1320"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1321"></span><span>    </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-var">UM</span></a></span><span> </span><span id="local-6989586621680853862"><span class="annot"><span class="annottext">UMState -&gt; UnifyResultM (UMState, a)
</span><a href="#local-6989586621680853862"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
forall a. (UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
</span><a href="GHC.Core.Unify.html#UM%27"><span class="hs-identifier hs-var">UM'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(UMState -&gt; UnifyResultM (UMState, a))
-&gt; UMState -&gt; UnifyResultM (UMState, a)
</span><span class="hs-identifier hs-var">oneShot</span></span><span> </span><span class="annot"><span class="annottext">UMState -&gt; UnifyResultM (UMState, a)
</span><a href="#local-6989586621680853862"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1322"></span><span>
</span><span id="line-1323"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680853852"><span id="local-6989586621680853854"><span id="local-6989586621680853856"><span class="annot"><a href="../../base/src/GHC.Base.html#Applicative"><span class="hs-identifier hs-type">Applicative</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1324"></span><span>      </span><span id="local-6989586621680853850"><span class="annot"><span class="annottext">pure :: forall a. a -&gt; UM a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var hs-var hs-var hs-var">pure</span></a></span></span><span> </span><span id="local-6989586621680853849"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680853849"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
forall a. (UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
</span><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-var">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621680853848"><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853848"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(UMState, a) -&gt; UnifyResultM (UMState, a)
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853848"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680853849"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1325"></span><span>      </span><span id="local-6989586621680853846"><span class="annot"><span class="annottext">&lt;*&gt; :: forall a b. UM (a -&gt; b) -&gt; UM a -&gt; UM b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">(&lt;*&gt;)</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UM (a -&gt; b) -&gt; UM a -&gt; UM b
forall (m :: * -&gt; *) a b. Monad m =&gt; m (a -&gt; b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#ap"><span class="hs-identifier hs-var">ap</span></a></span><span>
</span><span id="line-1326"></span><span>
</span><span id="line-1327"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680853839"><span id="local-6989586621680853841"><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1328"></span><span>  </span><span id="local-6989586621680853837"><span class="annot"><span class="annottext">UM a
</span><a href="#local-6989586621680853837"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621680853836"><span class="annot"><span class="annottext">&gt;&gt;= :: forall a b. UM a -&gt; (a -&gt; UM b) -&gt; UM b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var hs-var hs-var hs-var">&gt;&gt;=</span></a></span></span><span> </span><span id="local-6989586621680853835"><span class="annot"><span class="annottext">a -&gt; UM b
</span><a href="#local-6989586621680853835"><span class="hs-identifier hs-var">k</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UMState -&gt; UnifyResultM (UMState, b)) -&gt; UM b
forall a. (UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
</span><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-var">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621680853834"><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853834"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1329"></span><span>                  </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853833"><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853833"><span class="hs-identifier hs-var">state'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853832"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680853832"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UM a -&gt; UMState -&gt; UnifyResultM (UMState, a)
forall a. UM a -&gt; UMState -&gt; UnifyResultM (UMState, a)
</span><a href="GHC.Core.Unify.html#unUM"><span class="hs-identifier hs-var hs-var">unUM</span></a></span><span> </span><span class="annot"><span class="annottext">UM a
</span><a href="#local-6989586621680853837"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853834"><span class="hs-identifier hs-var">state</span></a></span><span>
</span><span id="line-1330"></span><span>                     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">UM b -&gt; UMState -&gt; UnifyResultM (UMState, b)
forall a. UM a -&gt; UMState -&gt; UnifyResultM (UMState, a)
</span><a href="GHC.Core.Unify.html#unUM"><span class="hs-identifier hs-var hs-var">unUM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; UM b
</span><a href="#local-6989586621680853835"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680853832"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853833"><span class="hs-identifier hs-var">state'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1331"></span><span>
</span><span id="line-1332"></span><span class="hs-comment">-- need this instance because of a use of 'guard' above</span><span>
</span><span id="line-1333"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680853824"><span id="local-6989586621680853826"><span class="annot"><a href="../../base/src/GHC.Base.html#Alternative"><span class="hs-identifier hs-type">Alternative</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1334"></span><span>  </span><span id="local-6989586621680853822"><span class="annot"><span class="annottext">empty :: forall a. UM a
</span><a href="#local-6989586621680853822"><span class="hs-identifier hs-var hs-var hs-var hs-var">empty</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
forall a. (UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
</span><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-var">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">UMState
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UnifyResultM (UMState, a)
forall (f :: * -&gt; *) a. Alternative f =&gt; f a
</span><a href="../../base/src/GHC.Base.html#empty"><span class="hs-identifier hs-var">Control.Applicative.empty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1335"></span><span>  </span><span id="local-6989586621680853820"><span class="annot"><span class="annottext">UM a
</span><a href="#local-6989586621680853820"><span class="hs-identifier hs-var">m1</span></a></span></span><span> </span><span id="local-6989586621680853819"><span class="annot"><span class="annottext">&lt;|&gt; :: forall a. UM a -&gt; UM a -&gt; UM a
</span><a href="#local-6989586621680853819"><span class="hs-operator hs-var hs-var hs-var hs-var">&lt;|&gt;</span></a></span></span><span> </span><span id="local-6989586621680853818"><span class="annot"><span class="annottext">UM a
</span><a href="#local-6989586621680853818"><span class="hs-identifier hs-var">m2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
forall a. (UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
</span><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-var">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621680853817"><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853817"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1336"></span><span>                  </span><span class="annot"><span class="annottext">UM a -&gt; UMState -&gt; UnifyResultM (UMState, a)
forall a. UM a -&gt; UMState -&gt; UnifyResultM (UMState, a)
</span><a href="GHC.Core.Unify.html#unUM"><span class="hs-identifier hs-var hs-var">unUM</span></a></span><span> </span><span class="annot"><span class="annottext">UM a
</span><a href="#local-6989586621680853820"><span class="hs-identifier hs-var">m1</span></a></span><span> </span><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853817"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="annot"><span class="annottext">UnifyResultM (UMState, a)
-&gt; UnifyResultM (UMState, a) -&gt; UnifyResultM (UMState, a)
forall (f :: * -&gt; *) a. Alternative f =&gt; f a -&gt; f a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#%3C%7C%3E"><span class="hs-operator hs-var">&lt;|&gt;</span></a></span><span>
</span><span id="line-1337"></span><span>                  </span><span class="annot"><span class="annottext">UM a -&gt; UMState -&gt; UnifyResultM (UMState, a)
forall a. UM a -&gt; UMState -&gt; UnifyResultM (UMState, a)
</span><a href="GHC.Core.Unify.html#unUM"><span class="hs-identifier hs-var hs-var">unUM</span></a></span><span> </span><span class="annot"><span class="annottext">UM a
</span><a href="#local-6989586621680853818"><span class="hs-identifier hs-var">m2</span></a></span><span> </span><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853817"><span class="hs-identifier hs-var">state</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1338"></span><span>
</span><span id="line-1339"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680853809"><span id="local-6989586621680853811"><span class="annot"><a href="../../base/src/GHC.Base.html#MonadPlus"><span class="hs-identifier hs-type">MonadPlus</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span></span></span><span>
</span><span id="line-1340"></span><span>
</span><span id="line-1341"></span><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.Fail.html#MonadFail"><span class="hs-identifier hs-type">MonadFail</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1342"></span><span>    </span><span id="local-6989586621680853803"><span class="annot"><span class="annottext">fail :: forall a. String -&gt; UM a
</span><a href="../../base/src/Control.Monad.Fail.html#fail"><span class="hs-identifier hs-var hs-var hs-var hs-var">fail</span></a></span></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
forall a. (UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
</span><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-var">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">UMState
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UnifyResultM (UMState, a)
forall a. UnifyResultM a
</span><a href="GHC.Core.Unify.html#SurelyApart"><span class="hs-identifier hs-var">SurelyApart</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- failed pattern match</span><span>
</span><span id="line-1343"></span><span>
</span><span id="line-1344"></span><span id="local-6989586621680854539"><span class="annot"><a href="GHC.Core.Unify.html#initUM"><span class="hs-identifier hs-type">initUM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span>  </span><span class="hs-comment">-- subst to extend</span><span>
</span><span id="line-1345"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span>
</span><span id="line-1346"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680854539"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UnifyResultM"><span class="hs-identifier hs-type">UnifyResultM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680854539"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-1347"></span><span id="initUM"><span class="annot"><span class="annottext">initUM :: forall a. TvSubstEnv -&gt; CvSubstEnv -&gt; UM a -&gt; UnifyResultM a
</span><a href="GHC.Core.Unify.html#initUM"><span class="hs-identifier hs-var hs-var">initUM</span></a></span></span><span> </span><span id="local-6989586621680853802"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680853802"><span class="hs-identifier hs-var">subst_env</span></a></span></span><span> </span><span id="local-6989586621680853801"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853801"><span class="hs-identifier hs-var">cv_subst_env</span></a></span></span><span> </span><span id="local-6989586621680853800"><span class="annot"><span class="annottext">UM a
</span><a href="#local-6989586621680853800"><span class="hs-identifier hs-var">um</span></a></span></span><span>
</span><span id="line-1348"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">UM a -&gt; UMState -&gt; UnifyResultM (UMState, a)
forall a. UM a -&gt; UMState -&gt; UnifyResultM (UMState, a)
</span><a href="GHC.Core.Unify.html#unUM"><span class="hs-identifier hs-var hs-var">unUM</span></a></span><span> </span><span class="annot"><span class="annottext">UM a
</span><a href="#local-6989586621680853800"><span class="hs-identifier hs-var">um</span></a></span><span> </span><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853799"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1349"></span><span>      </span><span class="annot"><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-type">Unifiable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMState
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853798"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680853798"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">a -&gt; UnifyResultM a
forall a. a -&gt; UnifyResultM a
</span><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-var">Unifiable</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680853798"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-1350"></span><span>      </span><span class="annot"><a href="GHC.Core.Unify.html#MaybeApart"><span class="hs-identifier hs-type">MaybeApart</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMState
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853797"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680853797"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">a -&gt; UnifyResultM a
forall a. a -&gt; UnifyResultM a
</span><a href="GHC.Core.Unify.html#MaybeApart"><span class="hs-identifier hs-var">MaybeApart</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680853797"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-1351"></span><span>      </span><span class="annot"><span class="annottext">UnifyResultM (UMState, a)
</span><a href="GHC.Core.Unify.html#SurelyApart"><span class="hs-identifier hs-var">SurelyApart</span></a></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UnifyResultM a
forall a. UnifyResultM a
</span><a href="GHC.Core.Unify.html#SurelyApart"><span class="hs-identifier hs-var">SurelyApart</span></a></span><span>
</span><span id="line-1352"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1353"></span><span>    </span><span id="local-6989586621680853799"><span class="annot"><span class="annottext">state :: UMState
</span><a href="#local-6989586621680853799"><span class="hs-identifier hs-var hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMState :: TvSubstEnv -&gt; CvSubstEnv -&gt; UMState
</span><a href="GHC.Core.Unify.html#UMState"><span class="hs-identifier hs-type">UMState</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">um_tv_env :: TvSubstEnv
</span><a href="GHC.Core.Unify.html#um_tv_env"><span class="hs-identifier hs-var">um_tv_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680853802"><span class="hs-identifier hs-var">subst_env</span></a></span><span>
</span><span id="line-1354"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">um_cv_env :: CvSubstEnv
</span><a href="GHC.Core.Unify.html#um_cv_env"><span class="hs-identifier hs-var">um_cv_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853801"><span class="hs-identifier hs-var">cv_subst_env</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1355"></span><span>
</span><span id="line-1356"></span><span class="annot"><a href="GHC.Core.Unify.html#tvBindFlag"><span class="hs-identifier hs-type">tvBindFlag</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-type">UMEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutTyVar"><span class="hs-identifier hs-type">OutTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#BindFlag"><span class="hs-identifier hs-type">BindFlag</span></a></span><span>
</span><span id="line-1357"></span><span id="tvBindFlag"><span class="annot"><span class="annottext">tvBindFlag :: UMEnv -&gt; OutTyVar -&gt; BindFlag
</span><a href="GHC.Core.Unify.html#tvBindFlag"><span class="hs-identifier hs-var hs-var">tvBindFlag</span></a></span></span><span> </span><span id="local-6989586621680853796"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853796"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680853795"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853795"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-1358"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853795"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; VarSet
</span><a href="GHC.Core.Unify.html#um_skols"><span class="hs-identifier hs-var hs-var">um_skols</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853796"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BindFlag
</span><a href="GHC.Core.Unify.html#Skolem"><span class="hs-identifier hs-var">Skolem</span></a></span><span>
</span><span id="line-1359"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; OutTyVar -&gt; BindFlag
</span><a href="GHC.Core.Unify.html#um_bind_fun"><span class="hs-identifier hs-var hs-var">um_bind_fun</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853796"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853795"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-1360"></span><span>
</span><span id="line-1361"></span><span class="annot"><a href="GHC.Core.Unify.html#getTvSubstEnv"><span class="hs-identifier hs-type">getTvSubstEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TvSubstEnv"><span class="hs-identifier hs-type">TvSubstEnv</span></a></span><span>
</span><span id="line-1362"></span><span id="getTvSubstEnv"><span class="annot"><span class="annottext">getTvSubstEnv :: UM TvSubstEnv
</span><a href="GHC.Core.Unify.html#getTvSubstEnv"><span class="hs-identifier hs-var hs-var">getTvSubstEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UMState -&gt; UnifyResultM (UMState, TvSubstEnv)) -&gt; UM TvSubstEnv
forall a. (UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
</span><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-var">UM</span></a></span><span> </span><span class="annot"><span class="annottext">((UMState -&gt; UnifyResultM (UMState, TvSubstEnv)) -&gt; UM TvSubstEnv)
-&gt; (UMState -&gt; UnifyResultM (UMState, TvSubstEnv)) -&gt; UM TvSubstEnv
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680853794"><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853794"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(UMState, TvSubstEnv) -&gt; UnifyResultM (UMState, TvSubstEnv)
forall a. a -&gt; UnifyResultM a
</span><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-var">Unifiable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853794"><span class="hs-identifier hs-var">state</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UMState -&gt; TvSubstEnv
</span><a href="GHC.Core.Unify.html#um_tv_env"><span class="hs-identifier hs-var hs-var">um_tv_env</span></a></span><span> </span><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853794"><span class="hs-identifier hs-var">state</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1363"></span><span>
</span><span id="line-1364"></span><span class="annot"><a href="GHC.Core.Unify.html#getCvSubstEnv"><span class="hs-identifier hs-type">getCvSubstEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#CvSubstEnv"><span class="hs-identifier hs-type">CvSubstEnv</span></a></span><span>
</span><span id="line-1365"></span><span id="getCvSubstEnv"><span class="annot"><span class="annottext">getCvSubstEnv :: UM CvSubstEnv
</span><a href="GHC.Core.Unify.html#getCvSubstEnv"><span class="hs-identifier hs-var hs-var">getCvSubstEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UMState -&gt; UnifyResultM (UMState, CvSubstEnv)) -&gt; UM CvSubstEnv
forall a. (UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
</span><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-var">UM</span></a></span><span> </span><span class="annot"><span class="annottext">((UMState -&gt; UnifyResultM (UMState, CvSubstEnv)) -&gt; UM CvSubstEnv)
-&gt; (UMState -&gt; UnifyResultM (UMState, CvSubstEnv)) -&gt; UM CvSubstEnv
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680853793"><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853793"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(UMState, CvSubstEnv) -&gt; UnifyResultM (UMState, CvSubstEnv)
forall a. a -&gt; UnifyResultM a
</span><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-var">Unifiable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853793"><span class="hs-identifier hs-var">state</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UMState -&gt; CvSubstEnv
</span><a href="GHC.Core.Unify.html#um_cv_env"><span class="hs-identifier hs-var hs-var">um_cv_env</span></a></span><span> </span><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853793"><span class="hs-identifier hs-var">state</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1366"></span><span>
</span><span id="line-1367"></span><span class="annot"><a href="GHC.Core.Unify.html#getSubst"><span class="hs-identifier hs-type">getSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-type">UMEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-1368"></span><span id="getSubst"><span class="annot"><span class="annottext">getSubst :: UMEnv -&gt; UM TCvSubst
</span><a href="GHC.Core.Unify.html#getSubst"><span class="hs-identifier hs-var hs-var">getSubst</span></a></span></span><span> </span><span id="local-6989586621680853792"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853792"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680853791"><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680853791"><span class="hs-identifier hs-var">tv_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UM TvSubstEnv
</span><a href="GHC.Core.Unify.html#getTvSubstEnv"><span class="hs-identifier hs-var">getTvSubstEnv</span></a></span><span>
</span><span id="line-1369"></span><span>                  </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680853790"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853790"><span class="hs-identifier hs-var">cv_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UM CvSubstEnv
</span><a href="GHC.Core.Unify.html#getCvSubstEnv"><span class="hs-identifier hs-var">getCvSubstEnv</span></a></span><span>
</span><span id="line-1370"></span><span>                  </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680853789"><span class="annot"><span class="annottext">in_scope :: InScopeSet
</span><a href="#local-6989586621680853789"><span class="hs-identifier hs-var hs-var">in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RnEnv2 -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#rnInScopeSet"><span class="hs-identifier hs-var">rnInScopeSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMEnv -&gt; RnEnv2
</span><a href="GHC.Core.Unify.html#um_rn_env"><span class="hs-identifier hs-var hs-var">um_rn_env</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853792"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1371"></span><span>                  </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; UM TCvSubst
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; (TvSubstEnv, CvSubstEnv) -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkTCvSubst"><span class="hs-identifier hs-var">mkTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680853789"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TvSubstEnv
</span><a href="#local-6989586621680853791"><span class="hs-identifier hs-var">tv_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853790"><span class="hs-identifier hs-var">cv_env</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1372"></span><span>
</span><span id="line-1373"></span><span class="annot"><a href="GHC.Core.Unify.html#extendTvEnv"><span class="hs-identifier hs-type">extendTvEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1374"></span><span id="extendTvEnv"><span class="annot"><span class="annottext">extendTvEnv :: OutTyVar -&gt; Type -&gt; UM ()
</span><a href="GHC.Core.Unify.html#extendTvEnv"><span class="hs-identifier hs-var hs-var">extendTvEnv</span></a></span></span><span> </span><span id="local-6989586621680853786"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853786"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621680853785"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853785"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UMState -&gt; UnifyResultM (UMState, ())) -&gt; UM ()
forall a. (UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
</span><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-var">UM</span></a></span><span> </span><span class="annot"><span class="annottext">((UMState -&gt; UnifyResultM (UMState, ())) -&gt; UM ())
-&gt; (UMState -&gt; UnifyResultM (UMState, ())) -&gt; UM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680853784"><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853784"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1375"></span><span>  </span><span class="annot"><span class="annottext">(UMState, ()) -&gt; UnifyResultM (UMState, ())
forall a. a -&gt; UnifyResultM a
</span><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-var">Unifiable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853784"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">um_tv_env :: TvSubstEnv
</span><a href="GHC.Core.Unify.html#um_tv_env"><span class="hs-identifier hs-var">um_tv_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TvSubstEnv -&gt; OutTyVar -&gt; Type -&gt; TvSubstEnv
forall a. VarEnv a -&gt; OutTyVar -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMState -&gt; TvSubstEnv
</span><a href="GHC.Core.Unify.html#um_tv_env"><span class="hs-identifier hs-var hs-var">um_tv_env</span></a></span><span> </span><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853784"><span class="hs-identifier hs-var">state</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853786"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853785"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1376"></span><span>
</span><span id="line-1377"></span><span class="annot"><a href="GHC.Core.Unify.html#extendCvEnv"><span class="hs-identifier hs-type">extendCvEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1378"></span><span id="extendCvEnv"><span class="annot"><span class="annottext">extendCvEnv :: OutTyVar -&gt; Coercion -&gt; UM ()
</span><a href="GHC.Core.Unify.html#extendCvEnv"><span class="hs-identifier hs-var hs-var">extendCvEnv</span></a></span></span><span> </span><span id="local-6989586621680853781"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853781"><span class="hs-identifier hs-var">cv</span></a></span></span><span> </span><span id="local-6989586621680853780"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853780"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UMState -&gt; UnifyResultM (UMState, ())) -&gt; UM ()
forall a. (UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
</span><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-var">UM</span></a></span><span> </span><span class="annot"><span class="annottext">((UMState -&gt; UnifyResultM (UMState, ())) -&gt; UM ())
-&gt; (UMState -&gt; UnifyResultM (UMState, ())) -&gt; UM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680853779"><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853779"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1379"></span><span>  </span><span class="annot"><span class="annottext">(UMState, ()) -&gt; UnifyResultM (UMState, ())
forall a. a -&gt; UnifyResultM a
</span><a href="GHC.Core.Unify.html#Unifiable"><span class="hs-identifier hs-var">Unifiable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853779"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">um_cv_env :: CvSubstEnv
</span><a href="GHC.Core.Unify.html#um_cv_env"><span class="hs-identifier hs-var">um_cv_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; OutTyVar -&gt; Coercion -&gt; CvSubstEnv
forall a. VarEnv a -&gt; OutTyVar -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMState -&gt; CvSubstEnv
</span><a href="GHC.Core.Unify.html#um_cv_env"><span class="hs-identifier hs-var hs-var">um_cv_env</span></a></span><span> </span><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853779"><span class="hs-identifier hs-var">state</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853781"><span class="hs-identifier hs-var">cv</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853780"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1380"></span><span>
</span><span id="line-1381"></span><span class="annot"><a href="GHC.Core.Unify.html#umRnBndr2"><span class="hs-identifier hs-type">umRnBndr2</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-type">UMEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-type">UMEnv</span></a></span><span>
</span><span id="line-1382"></span><span id="umRnBndr2"><span class="annot"><span class="annottext">umRnBndr2 :: UMEnv -&gt; OutTyVar -&gt; OutTyVar -&gt; UMEnv
</span><a href="GHC.Core.Unify.html#umRnBndr2"><span class="hs-identifier hs-var hs-var">umRnBndr2</span></a></span></span><span> </span><span id="local-6989586621680853778"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853778"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680853777"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853777"><span class="hs-identifier hs-var">v1</span></a></span></span><span> </span><span id="local-6989586621680853776"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853776"><span class="hs-identifier hs-var">v2</span></a></span></span><span>
</span><span id="line-1383"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853778"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">um_rn_env :: RnEnv2
</span><a href="GHC.Core.Unify.html#um_rn_env"><span class="hs-identifier hs-var">um_rn_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RnEnv2
</span><a href="#local-6989586621680853775"><span class="hs-identifier hs-var">rn_env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">um_skols :: VarSet
</span><a href="GHC.Core.Unify.html#um_skols"><span class="hs-identifier hs-var">um_skols</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; VarSet
</span><a href="GHC.Core.Unify.html#um_skols"><span class="hs-identifier hs-var hs-var">um_skols</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853778"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; OutTyVar -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-operator hs-var">`extendVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853773"><span class="hs-identifier hs-var">v'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1384"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1385"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680853775"><span class="annot"><span class="annottext">RnEnv2
</span><a href="#local-6989586621680853775"><span class="hs-identifier hs-var">rn_env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853773"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853773"><span class="hs-identifier hs-var">v'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RnEnv2 -&gt; OutTyVar -&gt; OutTyVar -&gt; (RnEnv2, OutTyVar)
</span><a href="GHC.Types.Var.Env.html#rnBndr2_var"><span class="hs-identifier hs-var">rnBndr2_var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMEnv -&gt; RnEnv2
</span><a href="GHC.Core.Unify.html#um_rn_env"><span class="hs-identifier hs-var hs-var">um_rn_env</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853778"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853777"><span class="hs-identifier hs-var">v1</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853776"><span class="hs-identifier hs-var">v2</span></a></span><span>
</span><span id="line-1386"></span><span>
</span><span id="line-1387"></span><span class="annot"><a href="GHC.Core.Unify.html#checkRnEnv"><span class="hs-identifier hs-type">checkRnEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-type">UMEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1388"></span><span id="checkRnEnv"><span class="annot"><span class="annottext">checkRnEnv :: UMEnv -&gt; VarSet -&gt; UM ()
</span><a href="GHC.Core.Unify.html#checkRnEnv"><span class="hs-identifier hs-var hs-var">checkRnEnv</span></a></span></span><span> </span><span id="local-6989586621680853771"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853771"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680853770"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680853770"><span class="hs-identifier hs-var">varset</span></a></span></span><span>
</span><span id="line-1389"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#isEmptyVarSet"><span class="hs-identifier hs-var">isEmptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680853768"><span class="hs-identifier hs-var">skol_vars</span></a></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; UM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1390"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680853770"><span class="hs-identifier hs-var">varset</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#disjointVarSet"><span class="hs-operator hs-var">`disjointVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680853768"><span class="hs-identifier hs-var">skol_vars</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; UM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1391"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UM ()
</span><a href="GHC.Core.Unify.html#maybeApart"><span class="hs-identifier hs-var">maybeApart</span></a></span><span>
</span><span id="line-1392"></span><span>               </span><span class="hs-comment">-- ToDo: why MaybeApart?</span><span>
</span><span id="line-1393"></span><span>               </span><span class="hs-comment">-- I think SurelyApart would be right</span><span>
</span><span id="line-1394"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1395"></span><span>    </span><span id="local-6989586621680853768"><span class="annot"><span class="annottext">skol_vars :: VarSet
</span><a href="#local-6989586621680853768"><span class="hs-identifier hs-var hs-var">skol_vars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv -&gt; VarSet
</span><a href="GHC.Core.Unify.html#um_skols"><span class="hs-identifier hs-var hs-var">um_skols</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853771"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-1396"></span><span>    </span><span class="hs-comment">-- NB: That isEmptyVarSet guard is a critical optimization;</span><span>
</span><span id="line-1397"></span><span>    </span><span class="hs-comment">-- it means we don't have to calculate the free vars of</span><span>
</span><span id="line-1398"></span><span>    </span><span class="hs-comment">-- the type, often saving quite a bit of allocation.</span><span>
</span><span id="line-1399"></span><span>
</span><span id="line-1400"></span><span class="hs-comment">-- | Converts any SurelyApart to a MaybeApart</span><span>
</span><span id="line-1401"></span><span class="annot"><a href="GHC.Core.Unify.html#don%27tBeSoSure"><span class="hs-identifier hs-type">don'tBeSoSure</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1402"></span><span id="don%27tBeSoSure"><span class="annot"><span class="annottext">don'tBeSoSure :: UM () -&gt; UM ()
</span><a href="GHC.Core.Unify.html#don%27tBeSoSure"><span class="hs-identifier hs-var hs-var">don'tBeSoSure</span></a></span></span><span> </span><span id="local-6989586621680853766"><span class="annot"><span class="annottext">UM ()
</span><a href="#local-6989586621680853766"><span class="hs-identifier hs-var">um</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UMState -&gt; UnifyResultM (UMState, ())) -&gt; UM ()
forall a. (UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
</span><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-var">UM</span></a></span><span> </span><span class="annot"><span class="annottext">((UMState -&gt; UnifyResultM (UMState, ())) -&gt; UM ())
-&gt; (UMState -&gt; UnifyResultM (UMState, ())) -&gt; UM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621680853765"><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853765"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1403"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">UM () -&gt; UMState -&gt; UnifyResultM (UMState, ())
forall a. UM a -&gt; UMState -&gt; UnifyResultM (UMState, a)
</span><a href="GHC.Core.Unify.html#unUM"><span class="hs-identifier hs-var hs-var">unUM</span></a></span><span> </span><span class="annot"><span class="annottext">UM ()
</span><a href="#local-6989586621680853766"><span class="hs-identifier hs-var">um</span></a></span><span> </span><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853765"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1404"></span><span>    </span><span class="annot"><span class="annottext">UnifyResultM (UMState, ())
</span><a href="GHC.Core.Unify.html#SurelyApart"><span class="hs-identifier hs-var">SurelyApart</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(UMState, ()) -&gt; UnifyResultM (UMState, ())
forall a. a -&gt; UnifyResultM a
</span><a href="GHC.Core.Unify.html#MaybeApart"><span class="hs-identifier hs-var">MaybeApart</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853765"><span class="hs-identifier hs-var">state</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1405"></span><span>    </span><span id="local-6989586621680853764"><span class="annot"><span class="annottext">UnifyResultM (UMState, ())
</span><a href="#local-6989586621680853764"><span class="hs-identifier hs-var">other</span></a></span></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UnifyResultM (UMState, ())
</span><a href="#local-6989586621680853764"><span class="hs-identifier hs-var">other</span></a></span><span>
</span><span id="line-1406"></span><span>
</span><span id="line-1407"></span><span class="annot"><a href="GHC.Core.Unify.html#umRnOccL"><span class="hs-identifier hs-type">umRnOccL</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-type">UMEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span>
</span><span id="line-1408"></span><span id="umRnOccL"><span class="annot"><span class="annottext">umRnOccL :: UMEnv -&gt; OutTyVar -&gt; OutTyVar
</span><a href="GHC.Core.Unify.html#umRnOccL"><span class="hs-identifier hs-var hs-var">umRnOccL</span></a></span></span><span> </span><span id="local-6989586621680853763"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853763"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680853762"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853762"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RnEnv2 -&gt; OutTyVar -&gt; OutTyVar
</span><a href="GHC.Types.Var.Env.html#rnOccL"><span class="hs-identifier hs-var">rnOccL</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMEnv -&gt; RnEnv2
</span><a href="GHC.Core.Unify.html#um_rn_env"><span class="hs-identifier hs-var hs-var">um_rn_env</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853763"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853762"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-1409"></span><span>
</span><span id="line-1410"></span><span class="annot"><a href="GHC.Core.Unify.html#umRnOccR"><span class="hs-identifier hs-type">umRnOccR</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-type">UMEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span>
</span><span id="line-1411"></span><span id="umRnOccR"><span class="annot"><span class="annottext">umRnOccR :: UMEnv -&gt; OutTyVar -&gt; OutTyVar
</span><a href="GHC.Core.Unify.html#umRnOccR"><span class="hs-identifier hs-var hs-var">umRnOccR</span></a></span></span><span> </span><span id="local-6989586621680853760"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853760"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680853759"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853759"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RnEnv2 -&gt; OutTyVar -&gt; OutTyVar
</span><a href="GHC.Types.Var.Env.html#rnOccR"><span class="hs-identifier hs-var">rnOccR</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMEnv -&gt; RnEnv2
</span><a href="GHC.Core.Unify.html#um_rn_env"><span class="hs-identifier hs-var hs-var">um_rn_env</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853760"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853759"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-1412"></span><span>
</span><span id="line-1413"></span><span class="annot"><a href="GHC.Core.Unify.html#umSwapRn"><span class="hs-identifier hs-type">umSwapRn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-type">UMEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UMEnv"><span class="hs-identifier hs-type">UMEnv</span></a></span><span>
</span><span id="line-1414"></span><span id="umSwapRn"><span class="annot"><span class="annottext">umSwapRn :: UMEnv -&gt; UMEnv
</span><a href="GHC.Core.Unify.html#umSwapRn"><span class="hs-identifier hs-var hs-var">umSwapRn</span></a></span></span><span> </span><span id="local-6989586621680853757"><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853757"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853757"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">um_rn_env :: RnEnv2
</span><a href="GHC.Core.Unify.html#um_rn_env"><span class="hs-identifier hs-var">um_rn_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RnEnv2 -&gt; RnEnv2
</span><a href="GHC.Types.Var.Env.html#rnSwap"><span class="hs-identifier hs-var">rnSwap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMEnv -&gt; RnEnv2
</span><a href="GHC.Core.Unify.html#um_rn_env"><span class="hs-identifier hs-var hs-var">um_rn_env</span></a></span><span> </span><span class="annot"><span class="annottext">UMEnv
</span><a href="#local-6989586621680853757"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1415"></span><span>
</span><span id="line-1416"></span><span class="annot"><a href="GHC.Core.Unify.html#maybeApart"><span class="hs-identifier hs-type">maybeApart</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1417"></span><span id="maybeApart"><span class="annot"><span class="annottext">maybeApart :: UM ()
</span><a href="GHC.Core.Unify.html#maybeApart"><span class="hs-identifier hs-var hs-var">maybeApart</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UMState -&gt; UnifyResultM (UMState, ())) -&gt; UM ()
forall a. (UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
</span><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-var">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621680853755"><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853755"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(UMState, ()) -&gt; UnifyResultM (UMState, ())
forall a. a -&gt; UnifyResultM a
</span><a href="GHC.Core.Unify.html#MaybeApart"><span class="hs-identifier hs-var">MaybeApart</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UMState
</span><a href="#local-6989586621680853755"><span class="hs-identifier hs-var">state</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1418"></span><span>
</span><span id="line-1419"></span><span id="local-6989586621680854504"><span class="annot"><a href="GHC.Core.Unify.html#surelyApart"><span class="hs-identifier hs-type">surelyApart</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-type">UM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680854504"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-1420"></span><span id="surelyApart"><span class="annot"><span class="annottext">surelyApart :: forall a. UM a
</span><a href="GHC.Core.Unify.html#surelyApart"><span class="hs-identifier hs-var hs-var">surelyApart</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
forall a. (UMState -&gt; UnifyResultM (UMState, a)) -&gt; UM a
</span><a href="GHC.Core.Unify.html#UM"><span class="hs-identifier hs-var">UM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">UMState
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UnifyResultM (UMState, a)
forall a. UnifyResultM a
</span><a href="GHC.Core.Unify.html#SurelyApart"><span class="hs-identifier hs-var">SurelyApart</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1421"></span><span>
</span><span id="line-1422"></span><span class="hs-comment">{-
%************************************************************************
%*                                                                      *
            Matching a (lifted) type against a coercion
%*                                                                      *
%************************************************************************

This section defines essentially an inverse to liftCoSubst. It is defined
here to avoid a dependency from Coercion on this module.

-}</span><span>
</span><span id="line-1433"></span><span>
</span><span id="line-1434"></span><span class="hs-keyword">data</span><span> </span><span id="MatchEnv"><span class="annot"><a href="GHC.Core.Unify.html#MatchEnv"><span class="hs-identifier hs-var">MatchEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="ME"><span class="annot"><a href="GHC.Core.Unify.html#ME"><span class="hs-identifier hs-var">ME</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="me_tmpls"><span class="annot"><span class="annottext">MatchEnv -&gt; VarSet
</span><a href="GHC.Core.Unify.html#me_tmpls"><span class="hs-identifier hs-var hs-var">me_tmpls</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyVarSet"><span class="hs-identifier hs-type">TyVarSet</span></a></span><span>
</span><span id="line-1435"></span><span>                   </span><span class="hs-special">,</span><span> </span><span id="me_env"><span class="annot"><span class="annottext">MatchEnv -&gt; RnEnv2
</span><a href="GHC.Core.Unify.html#me_env"><span class="hs-identifier hs-var hs-var">me_env</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#RnEnv2"><span class="hs-identifier hs-type">RnEnv2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1436"></span><span>
</span><span id="line-1437"></span><span class="hs-comment">-- | 'liftCoMatch' is sort of inverse to 'liftCoSubst'.  In particular, if</span><span>
</span><span id="line-1438"></span><span class="hs-comment">--   @liftCoMatch vars ty co == Just s@, then @liftCoSubst s ty == co@,</span><span>
</span><span id="line-1439"></span><span class="hs-comment">--   where @==@ there means that the result of 'liftCoSubst' has the same</span><span>
</span><span id="line-1440"></span><span class="hs-comment">--   type as the original co; but may be different under the hood.</span><span>
</span><span id="line-1441"></span><span class="hs-comment">--   That is, it matches a type against a coercion of the same</span><span>
</span><span id="line-1442"></span><span class="hs-comment">--   &quot;shape&quot;, and returns a lifting substitution which could have been</span><span>
</span><span id="line-1443"></span><span class="hs-comment">--   used to produce the given coercion from the given type.</span><span>
</span><span id="line-1444"></span><span class="hs-comment">--   Note that this function is incomplete -- it might return Nothing</span><span>
</span><span id="line-1445"></span><span class="hs-comment">--   when there does indeed exist a possible lifting context.</span><span>
</span><span id="line-1446"></span><span class="hs-comment">--</span><span>
</span><span id="line-1447"></span><span class="hs-comment">-- This function is incomplete in that it doesn't respect the equality</span><span>
</span><span id="line-1448"></span><span class="hs-comment">-- in `eqType`. That is, it's possible that this will succeed for t1 and</span><span>
</span><span id="line-1449"></span><span class="hs-comment">-- fail for t2, even when t1 `eqType` t2. That's because it depends on</span><span>
</span><span id="line-1450"></span><span class="hs-comment">-- there being a very similar structure between the type and the coercion.</span><span>
</span><span id="line-1451"></span><span class="hs-comment">-- This incompleteness shouldn't be all that surprising, especially because</span><span>
</span><span id="line-1452"></span><span class="hs-comment">-- it depends on the structure of the coercion, which is a silly thing to do.</span><span>
</span><span id="line-1453"></span><span class="hs-comment">--</span><span>
</span><span id="line-1454"></span><span class="hs-comment">-- The lifting context produced doesn't have to be exacting in the roles</span><span>
</span><span id="line-1455"></span><span class="hs-comment">-- of the mappings. This is because any use of the lifting context will</span><span>
</span><span id="line-1456"></span><span class="hs-comment">-- also require a desired role. Thus, this algorithm prefers mapping to</span><span>
</span><span id="line-1457"></span><span class="hs-comment">-- nominal coercions where it can do so.</span><span>
</span><span id="line-1458"></span><span class="annot"><a href="GHC.Core.Unify.html#liftCoMatch"><span class="hs-identifier hs-type">liftCoMatch</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyCoVarSet"><span class="hs-identifier hs-type">TyCoVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#LiftingContext"><span class="hs-identifier hs-type">LiftingContext</span></a></span><span>
</span><span id="line-1459"></span><span id="liftCoMatch"><span class="annot"><span class="annottext">liftCoMatch :: VarSet -&gt; Type -&gt; Coercion -&gt; Maybe LiftingContext
</span><a href="GHC.Core.Unify.html#liftCoMatch"><span class="hs-identifier hs-var hs-var">liftCoMatch</span></a></span></span><span> </span><span id="local-6989586621680853751"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680853751"><span class="hs-identifier hs-var">tmpls</span></a></span></span><span> </span><span id="local-6989586621680853750"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853750"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680853749"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853749"><span class="hs-identifier hs-var">co</span></a></span></span><span>
</span><span id="line-1460"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680853748"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853748"><span class="hs-identifier hs-var">cenv1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; Coercion
-&gt; Coercion
-&gt; Coercion
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853746"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853744"><span class="hs-identifier hs-var">ki</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853743"><span class="hs-identifier hs-var">ki_co</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853742"><span class="hs-identifier hs-var">ki_ki_co</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853742"><span class="hs-identifier hs-var">ki_ki_co</span></a></span><span>
</span><span id="line-1461"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680853741"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853741"><span class="hs-identifier hs-var">cenv2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; Coercion
-&gt; Coercion
-&gt; Coercion
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853746"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853748"><span class="hs-identifier hs-var">cenv1</span></a></span><span>       </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853750"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853749"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1462"></span><span>                              </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853740"><span class="hs-identifier hs-var">co_lkind</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853739"><span class="hs-identifier hs-var">co_rkind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1463"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LiftingContext -&gt; Maybe LiftingContext
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; CvSubstEnv -&gt; LiftingContext
</span><a href="GHC.Core.Coercion.html#LC"><span class="hs-identifier hs-var">LC</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkEmptyTCvSubst"><span class="hs-identifier hs-var">mkEmptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680853737"><span class="hs-identifier hs-var">in_scope</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853741"><span class="hs-identifier hs-var">cenv2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1464"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1465"></span><span>    </span><span id="local-6989586621680853746"><span class="annot"><span class="annottext">menv :: MatchEnv
</span><a href="#local-6989586621680853746"><span class="hs-identifier hs-var hs-var">menv</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ME :: VarSet -&gt; RnEnv2 -&gt; MatchEnv
</span><a href="GHC.Core.Unify.html#ME"><span class="hs-identifier hs-type">ME</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">me_tmpls :: VarSet
</span><a href="GHC.Core.Unify.html#me_tmpls"><span class="hs-identifier hs-var">me_tmpls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680853751"><span class="hs-identifier hs-var">tmpls</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">me_env :: RnEnv2
</span><a href="GHC.Core.Unify.html#me_env"><span class="hs-identifier hs-var">me_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; RnEnv2
</span><a href="GHC.Types.Var.Env.html#mkRnEnv2"><span class="hs-identifier hs-var">mkRnEnv2</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680853737"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1466"></span><span>    </span><span id="local-6989586621680853737"><span class="annot"><span class="annottext">in_scope :: InScopeSet
</span><a href="#local-6989586621680853737"><span class="hs-identifier hs-var hs-var">in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680853751"><span class="hs-identifier hs-var">tmpls</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfCo"><span class="hs-identifier hs-var">tyCoVarsOfCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853749"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1467"></span><span>    </span><span class="hs-comment">-- Like tcMatchTy, assume all the interesting variables</span><span>
</span><span id="line-1468"></span><span>    </span><span class="hs-comment">-- in ty are in tmpls</span><span>
</span><span id="line-1469"></span><span>
</span><span id="line-1470"></span><span>    </span><span id="local-6989586621680853744"><span class="annot"><span class="annottext">ki :: Type
</span><a href="#local-6989586621680853744"><span class="hs-identifier hs-var hs-var">ki</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Type
Type -&gt; Type
</span><a href="GHC.Core.Type.html#typeKind"><span class="hs-identifier hs-var">typeKind</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853750"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1471"></span><span>    </span><span id="local-6989586621680853743"><span class="annot"><span class="annottext">ki_co :: Coercion
</span><a href="#local-6989586621680853743"><span class="hs-identifier hs-var hs-var">ki_co</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#promoteCoercion"><span class="hs-identifier hs-var">promoteCoercion</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853749"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1472"></span><span>    </span><span id="local-6989586621680853742"><span class="annot"><span class="annottext">ki_ki_co :: Coercion
</span><a href="#local-6989586621680853742"><span class="hs-identifier hs-var hs-var">ki_ki_co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.html#liftedTypeKind"><span class="hs-identifier hs-var">liftedTypeKind</span></a></span><span>
</span><span id="line-1473"></span><span>
</span><span id="line-1474"></span><span>    </span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span id="local-6989586621680853740"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853740"><span class="hs-identifier hs-var">co_lkind</span></a></span></span><span> </span><span id="local-6989586621680853739"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853739"><span class="hs-identifier hs-var">co_rkind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Pair Type
</span><a href="GHC.Core.Coercion.html#coercionKind"><span class="hs-identifier hs-var">coercionKind</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853743"><span class="hs-identifier hs-var">ki_co</span></a></span><span>
</span><span id="line-1475"></span><span>
</span><span id="line-1476"></span><span class="hs-comment">-- | 'ty_co_match' does all the actual work for 'liftCoMatch'.</span><span>
</span><span id="line-1477"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-type">ty_co_match</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#MatchEnv"><span class="hs-identifier hs-type">MatchEnv</span></a></span><span>   </span><span class="hs-comment">-- ^ ambient helpful info</span><span>
</span><span id="line-1478"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#LiftCoEnv"><span class="hs-identifier hs-type">LiftCoEnv</span></a></span><span>  </span><span class="hs-comment">-- ^ incoming subst</span><span>
</span><span id="line-1479"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>       </span><span class="hs-comment">-- ^ ty, type to match</span><span>
</span><span id="line-1480"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>   </span><span class="hs-comment">-- ^ co, coercion to match against</span><span>
</span><span id="line-1481"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>   </span><span class="hs-comment">-- ^ :: kind of L type of substed ty ~N L kind of co</span><span>
</span><span id="line-1482"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>   </span><span class="hs-comment">-- ^ :: kind of R type of substed ty ~N R kind of co</span><span>
</span><span id="line-1483"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#LiftCoEnv"><span class="hs-identifier hs-type">LiftCoEnv</span></a></span><span>
</span><span id="line-1484"></span><span id="ty_co_match"><span class="annot"><span class="annottext">ty_co_match :: MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; Coercion
-&gt; Coercion
-&gt; Coercion
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var hs-var">ty_co_match</span></a></span></span><span> </span><span id="local-6989586621680853731"><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853731"><span class="hs-identifier hs-var">menv</span></a></span></span><span> </span><span id="local-6989586621680853730"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853730"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680853729"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853729"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680853728"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853728"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621680853727"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853727"><span class="hs-identifier hs-var">lkco</span></a></span></span><span> </span><span id="local-6989586621680853726"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853726"><span class="hs-identifier hs-var">rkco</span></a></span></span><span>
</span><span id="line-1485"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680853725"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853725"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe Type
</span><a href="GHC.Core.Type.html#coreView"><span class="hs-identifier hs-var">coreView</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853729"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; Coercion
-&gt; Coercion
-&gt; Coercion
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853731"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853730"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853725"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853728"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853727"><span class="hs-identifier hs-var">lkco</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853726"><span class="hs-identifier hs-var">rkco</span></a></span><span>
</span><span id="line-1486"></span><span>
</span><span id="line-1487"></span><span>  </span><span class="hs-comment">-- handle Refl case:</span><span>
</span><span id="line-1488"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853729"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; CvSubstEnv -&gt; Bool
forall a. VarSet -&gt; VarEnv a -&gt; Bool
</span><a href="#local-6989586621680853724"><span class="hs-operator hs-var">`isNotInDomainOf`</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853730"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-1489"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853723"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853723"><span class="hs-identifier hs-var">ty'</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Role
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Maybe (Type, Role)
</span><a href="GHC.Core.Coercion.html#isReflCo_maybe"><span class="hs-identifier hs-var">isReflCo_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853728"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1490"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853729"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Bool
</span><a href="GHC.Core.Type.html#eqType"><span class="hs-operator hs-var">`eqType`</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853723"><span class="hs-identifier hs-var">ty'</span></a></span><span>
</span><span id="line-1491"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; Maybe CvSubstEnv
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853730"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-1492"></span><span>
</span><span id="line-1493"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1494"></span><span>    </span><span id="local-6989586621680854476"><span class="annot"><a href="#local-6989586621680853724"><span class="hs-identifier hs-type">isNotInDomainOf</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#VarEnv"><span class="hs-identifier hs-type">VarEnv</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680854476"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span><span>
</span><span id="line-1495"></span><span>    </span><span id="local-6989586621680853724"><span class="annot"><span class="annottext">isNotInDomainOf :: forall a. VarSet -&gt; VarEnv a -&gt; Bool
</span><a href="#local-6989586621680853724"><span class="hs-identifier hs-var hs-var">isNotInDomainOf</span></a></span></span><span> </span><span id="local-6989586621680853721"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680853721"><span class="hs-identifier hs-var">set</span></a></span></span><span> </span><span id="local-6989586621680853720"><span class="annot"><span class="annottext">VarEnv a
</span><a href="#local-6989586621680853720"><span class="hs-identifier hs-var">env</span></a></span></span><span>
</span><span id="line-1496"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; Bool) -&gt; VarSet -&gt; Bool
</span><a href="#local-6989586621680853719"><span class="hs-identifier hs-var">noneSet</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621680853718"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853718"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; VarEnv a -&gt; Bool
forall a. OutTyVar -&gt; VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#elemVarEnv"><span class="hs-identifier hs-var">elemVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853718"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv a
</span><a href="#local-6989586621680853720"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621680853721"><span class="hs-identifier hs-var">set</span></a></span><span>
</span><span id="line-1497"></span><span>
</span><span id="line-1498"></span><span>    </span><span class="annot"><a href="#local-6989586621680853719"><span class="hs-identifier hs-type">noneSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1499"></span><span>    </span><span id="local-6989586621680853719"><span class="annot"><span class="annottext">noneSet :: (OutTyVar -&gt; Bool) -&gt; VarSet -&gt; Bool
</span><a href="#local-6989586621680853719"><span class="hs-identifier hs-var hs-var">noneSet</span></a></span></span><span> </span><span id="local-6989586621680853716"><span class="annot"><span class="annottext">OutTyVar -&gt; Bool
</span><a href="#local-6989586621680853716"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; Bool) -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#allVarSet"><span class="hs-identifier hs-var">allVarSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; (OutTyVar -&gt; Bool) -&gt; OutTyVar -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; Bool
</span><a href="#local-6989586621680853716"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1500"></span><span>
</span><span id="line-1501"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span id="local-6989586621680853714"><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853714"><span class="hs-identifier hs-var">menv</span></a></span></span><span> </span><span id="local-6989586621680853713"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853713"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680853712"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853712"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680853711"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853711"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621680853710"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853710"><span class="hs-identifier hs-var">lkco</span></a></span></span><span> </span><span id="local-6989586621680853709"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853709"><span class="hs-identifier hs-var">rkco</span></a></span></span><span>
</span><span id="line-1502"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CastTy"><span class="hs-identifier hs-type">CastTy</span></a></span><span> </span><span id="local-6989586621680853708"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853708"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span id="local-6989586621680853707"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853707"><span class="hs-identifier hs-var">co'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853712"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1503"></span><span>     </span><span class="hs-comment">-- See Note [Matching in the presence of casts (1)]</span><span>
</span><span id="line-1504"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680853706"><span class="annot"><span class="annottext">empty_subst :: TCvSubst
</span><a href="#local-6989586621680853706"><span class="hs-identifier hs-var hs-var">empty_subst</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkEmptyTCvSubst"><span class="hs-identifier hs-var">mkEmptyTCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RnEnv2 -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#rnInScopeSet"><span class="hs-identifier hs-var">rnInScopeSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MatchEnv -&gt; RnEnv2
</span><a href="GHC.Core.Unify.html#me_env"><span class="hs-identifier hs-var hs-var">me_env</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853714"><span class="hs-identifier hs-var">menv</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1505"></span><span>        </span><span id="local-6989586621680853703"><span class="annot"><span class="annottext">substed_co_l :: Coercion
</span><a href="#local-6989586621680853703"><span class="hs-identifier hs-var hs-var">substed_co_l</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Coercion -&gt; Coercion
TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCo"><span class="hs-identifier hs-var">substCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.Coercion.html#liftEnvSubstLeft"><span class="hs-identifier hs-var">liftEnvSubstLeft</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680853706"><span class="hs-identifier hs-var">empty_subst</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853713"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span>  </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853707"><span class="hs-identifier hs-var">co'</span></a></span><span>
</span><span id="line-1506"></span><span>        </span><span id="local-6989586621680853699"><span class="annot"><span class="annottext">substed_co_r :: Coercion
</span><a href="#local-6989586621680853699"><span class="hs-identifier hs-var hs-var">substed_co_r</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Coercion -&gt; Coercion
TCvSubst -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Subst.html#substCo"><span class="hs-identifier hs-var">substCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; CvSubstEnv -&gt; TCvSubst
</span><a href="GHC.Core.Coercion.html#liftEnvSubstRight"><span class="hs-identifier hs-var">liftEnvSubstRight</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680853706"><span class="hs-identifier hs-var">empty_subst</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853713"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853707"><span class="hs-identifier hs-var">co'</span></a></span><span>
</span><span id="line-1507"></span><span>    </span><span class="hs-keyword">in</span><span>
</span><span id="line-1508"></span><span>    </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; Coercion
-&gt; Coercion
-&gt; Coercion
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853714"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853713"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853708"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853711"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853703"><span class="hs-identifier hs-var">substed_co_l</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkTransCo"><span class="hs-operator hs-var">`mkTransCo`</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853710"><span class="hs-identifier hs-var">lkco</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1509"></span><span>                                  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853699"><span class="hs-identifier hs-var">substed_co_r</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkTransCo"><span class="hs-operator hs-var">`mkTransCo`</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853709"><span class="hs-identifier hs-var">rkco</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1510"></span><span>
</span><span id="line-1511"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#SymCo"><span class="hs-identifier hs-type">SymCo</span></a></span><span> </span><span id="local-6989586621680853696"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853696"><span class="hs-identifier hs-var">co'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853711"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1512"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; CvSubstEnv
</span><a href="GHC.Core.Coercion.html#swapLiftCoEnv"><span class="hs-identifier hs-var">swapLiftCoEnv</span></a></span><span> </span><span class="annot"><span class="annottext">(CvSubstEnv -&gt; CvSubstEnv) -&gt; Maybe CvSubstEnv -&gt; Maybe CvSubstEnv
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; Coercion
-&gt; Coercion
-&gt; Coercion
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853714"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CvSubstEnv -&gt; CvSubstEnv
</span><a href="GHC.Core.Coercion.html#swapLiftCoEnv"><span class="hs-identifier hs-var">swapLiftCoEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853713"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853712"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853696"><span class="hs-identifier hs-var">co'</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853709"><span class="hs-identifier hs-var">rkco</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853710"><span class="hs-identifier hs-var">lkco</span></a></span><span>
</span><span id="line-1513"></span><span>
</span><span id="line-1514"></span><span>  </span><span class="hs-comment">-- Match a type variable against a non-refl coercion</span><span>
</span><span id="line-1515"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span id="local-6989586621680853694"><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853694"><span class="hs-identifier hs-var">menv</span></a></span></span><span> </span><span id="local-6989586621680853693"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853693"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621680853692"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853692"><span class="hs-identifier hs-var">tv1</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680853691"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853691"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621680853690"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853690"><span class="hs-identifier hs-var">lkco</span></a></span></span><span> </span><span id="local-6989586621680853689"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853689"><span class="hs-identifier hs-var">rkco</span></a></span></span><span>
</span><span id="line-1516"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680853688"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853688"><span class="hs-identifier hs-var">co1'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; OutTyVar -&gt; Maybe Coercion
forall a. VarEnv a -&gt; OutTyVar -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853693"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853687"><span class="hs-identifier hs-var">tv1'</span></a></span><span> </span><span class="hs-comment">-- tv1' is already bound to co1</span><span>
</span><span id="line-1517"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">RnEnv2 -&gt; Coercion -&gt; Coercion -&gt; Bool
</span><a href="GHC.Core.Coercion.html#eqCoercionX"><span class="hs-identifier hs-var">eqCoercionX</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RnEnv2 -&gt; RnEnv2
</span><a href="GHC.Types.Var.Env.html#nukeRnEnvL"><span class="hs-identifier hs-var">nukeRnEnvL</span></a></span><span> </span><span class="annot"><span class="annottext">RnEnv2
</span><a href="#local-6989586621680853684"><span class="hs-identifier hs-var">rn_env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853688"><span class="hs-identifier hs-var">co1'</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853691"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1518"></span><span>    </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; Maybe CvSubstEnv
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853693"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-1519"></span><span>    </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Maybe CvSubstEnv
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>       </span><span class="hs-comment">-- no match since tv1 matches two different coercions</span><span>
</span><span id="line-1520"></span><span>
</span><span id="line-1521"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853687"><span class="hs-identifier hs-var">tv1'</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv -&gt; VarSet
</span><a href="GHC.Core.Unify.html#me_tmpls"><span class="hs-identifier hs-var hs-var">me_tmpls</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853694"><span class="hs-identifier hs-var">menv</span></a></span><span>           </span><span class="hs-comment">-- tv1' is a template var</span><span>
</span><span id="line-1522"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">(OutTyVar -&gt; Bool) -&gt; [OutTyVar] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RnEnv2 -&gt; OutTyVar -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#inRnEnvR"><span class="hs-identifier hs-var">inRnEnvR</span></a></span><span> </span><span class="annot"><span class="annottext">RnEnv2
</span><a href="#local-6989586621680853684"><span class="hs-identifier hs-var">rn_env</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; [OutTyVar]
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfCoList"><span class="hs-identifier hs-var">tyCoVarsOfCoList</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853691"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1523"></span><span>    </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe CvSubstEnv
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>      </span><span class="hs-comment">-- occurs check failed</span><span>
</span><span id="line-1524"></span><span>    </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; Maybe CvSubstEnv
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(CvSubstEnv -&gt; Maybe CvSubstEnv) -&gt; CvSubstEnv -&gt; Maybe CvSubstEnv
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; OutTyVar -&gt; Coercion -&gt; CvSubstEnv
forall a. VarEnv a -&gt; OutTyVar -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853693"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853687"><span class="hs-identifier hs-var">tv1'</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; CvSubstEnv) -&gt; Coercion -&gt; CvSubstEnv
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1525"></span><span>                </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#castCoercionKind"><span class="hs-identifier hs-var">castCoercionKind</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853691"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkSymCo"><span class="hs-identifier hs-var">mkSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853690"><span class="hs-identifier hs-var">lkco</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkSymCo"><span class="hs-identifier hs-var">mkSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853689"><span class="hs-identifier hs-var">rkco</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1526"></span><span>
</span><span id="line-1527"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1528"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe CvSubstEnv
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1529"></span><span>
</span><span id="line-1530"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1531"></span><span>    </span><span id="local-6989586621680853684"><span class="annot"><span class="annottext">rn_env :: RnEnv2
</span><a href="#local-6989586621680853684"><span class="hs-identifier hs-var hs-var">rn_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MatchEnv -&gt; RnEnv2
</span><a href="GHC.Core.Unify.html#me_env"><span class="hs-identifier hs-var hs-var">me_env</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853694"><span class="hs-identifier hs-var">menv</span></a></span><span>
</span><span id="line-1532"></span><span>    </span><span id="local-6989586621680853687"><span class="annot"><span class="annottext">tv1' :: OutTyVar
</span><a href="#local-6989586621680853687"><span class="hs-identifier hs-var hs-var">tv1'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RnEnv2 -&gt; OutTyVar -&gt; OutTyVar
</span><a href="GHC.Types.Var.Env.html#rnOccL"><span class="hs-identifier hs-var">rnOccL</span></a></span><span> </span><span class="annot"><span class="annottext">RnEnv2
</span><a href="#local-6989586621680853684"><span class="hs-identifier hs-var">rn_env</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853692"><span class="hs-identifier hs-var">tv1</span></a></span><span>
</span><span id="line-1533"></span><span>
</span><span id="line-1534"></span><span>  </span><span class="hs-comment">-- just look through SubCo's. We don't really care about roles here.</span><span>
</span><span id="line-1535"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span id="local-6989586621680853681"><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853681"><span class="hs-identifier hs-var">menv</span></a></span></span><span> </span><span id="local-6989586621680853680"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853680"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680853679"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853679"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#SubCo"><span class="hs-identifier hs-type">SubCo</span></a></span><span> </span><span id="local-6989586621680853677"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853677"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680853676"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853676"><span class="hs-identifier hs-var">lkco</span></a></span></span><span> </span><span id="local-6989586621680853675"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853675"><span class="hs-identifier hs-var">rkco</span></a></span></span><span>
</span><span id="line-1536"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; Coercion
-&gt; Coercion
-&gt; Coercion
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853681"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853680"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853679"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853677"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853676"><span class="hs-identifier hs-var">lkco</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853675"><span class="hs-identifier hs-var">rkco</span></a></span><span>
</span><span id="line-1537"></span><span>
</span><span id="line-1538"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span id="local-6989586621680853674"><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853674"><span class="hs-identifier hs-var">menv</span></a></span></span><span> </span><span id="local-6989586621680853673"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853673"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppTy"><span class="hs-identifier hs-type">AppTy</span></a></span><span> </span><span id="local-6989586621680853672"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853672"><span class="hs-identifier hs-var">ty1a</span></a></span></span><span> </span><span id="local-6989586621680853671"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853671"><span class="hs-identifier hs-var">ty1b</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680853670"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853670"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621680853669"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853669"><span class="hs-identifier hs-var">_lkco</span></a></span></span><span> </span><span id="local-6989586621680853668"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853668"><span class="hs-identifier hs-var">_rkco</span></a></span></span><span>
</span><span id="line-1539"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853667"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853667"><span class="hs-identifier hs-var">co2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853666"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853666"><span class="hs-identifier hs-var">arg2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Maybe (Coercion, Coercion)
</span><a href="GHC.Core.Coercion.html#splitAppCo_maybe"><span class="hs-identifier hs-var">splitAppCo_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853670"><span class="hs-identifier hs-var">co</span></a></span><span>     </span><span class="hs-comment">-- c.f. Unify.match on AppTy</span><span>
</span><span id="line-1540"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; [Type]
-&gt; Coercion
-&gt; [Coercion]
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match_app"><span class="hs-identifier hs-var">ty_co_match_app</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853674"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853673"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853672"><span class="hs-identifier hs-var">ty1a</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853671"><span class="hs-identifier hs-var">ty1b</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853667"><span class="hs-identifier hs-var">co2</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853666"><span class="hs-identifier hs-var">arg2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1541"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span id="local-6989586621680853663"><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853663"><span class="hs-identifier hs-var">menv</span></a></span></span><span> </span><span id="local-6989586621680853662"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853662"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680853661"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853661"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppCo"><span class="hs-identifier hs-type">AppCo</span></a></span><span> </span><span id="local-6989586621680853659"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853659"><span class="hs-identifier hs-var">co2</span></a></span></span><span> </span><span id="local-6989586621680853658"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853658"><span class="hs-identifier hs-var">arg2</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680853657"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853657"><span class="hs-identifier hs-var">_lkco</span></a></span></span><span> </span><span id="local-6989586621680853656"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853656"><span class="hs-identifier hs-var">_rkco</span></a></span></span><span>
</span><span id="line-1542"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853655"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853655"><span class="hs-identifier hs-var">ty1a</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853654"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853654"><span class="hs-identifier hs-var">ty1b</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (Type, Type)
Type -&gt; Maybe (Type, Type)
</span><a href="GHC.Core.Type.html#repSplitAppTy_maybe"><span class="hs-identifier hs-var">repSplitAppTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853661"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1543"></span><span>       </span><span class="hs-comment">-- yes, the one from Type, not TcType; this is for coercion optimization</span><span>
</span><span id="line-1544"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; [Type]
-&gt; Coercion
-&gt; [Coercion]
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match_app"><span class="hs-identifier hs-var">ty_co_match_app</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853663"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853662"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853655"><span class="hs-identifier hs-var">ty1a</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853654"><span class="hs-identifier hs-var">ty1b</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853659"><span class="hs-identifier hs-var">co2</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853658"><span class="hs-identifier hs-var">arg2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1545"></span><span>
</span><span id="line-1546"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span id="local-6989586621680853653"><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853653"><span class="hs-identifier hs-var">menv</span></a></span></span><span> </span><span id="local-6989586621680853652"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853652"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621680853650"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680853650"><span class="hs-identifier hs-var">tc1</span></a></span></span><span> </span><span id="local-6989586621680853649"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853649"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConAppCo"><span class="hs-identifier hs-type">TyConAppCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680853647"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680853647"><span class="hs-identifier hs-var">tc2</span></a></span></span><span> </span><span id="local-6989586621680853646"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853646"><span class="hs-identifier hs-var">cos</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680853645"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853645"><span class="hs-identifier hs-var">_lkco</span></a></span></span><span> </span><span id="local-6989586621680853644"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853644"><span class="hs-identifier hs-var">_rkco</span></a></span></span><span>
</span><span id="line-1547"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; TyCon
-&gt; [Type]
-&gt; TyCon
-&gt; [Coercion]
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match_tc"><span class="hs-identifier hs-var">ty_co_match_tc</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853653"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853652"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680853650"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853649"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680853647"><span class="hs-identifier hs-var">tc2</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853646"><span class="hs-identifier hs-var">cos</span></a></span><span>
</span><span id="line-1548"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span id="local-6989586621680853642"><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853642"><span class="hs-identifier hs-var">menv</span></a></span></span><span> </span><span id="local-6989586621680853641"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853641"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680853639"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853639"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span id="local-6989586621680853638"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853638"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621680853637"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853637"><span class="hs-identifier hs-var">ty2</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680853636"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853636"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621680853635"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853635"><span class="hs-identifier hs-var">_lkco</span></a></span></span><span> </span><span id="local-6989586621680853634"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853634"><span class="hs-identifier hs-var">_rkco</span></a></span></span><span>
</span><span id="line-1549"></span><span>    </span><span class="hs-comment">-- Despite the fact that (-&gt;) is polymorphic in five type variables (two</span><span>
</span><span id="line-1550"></span><span>    </span><span class="hs-comment">-- runtime rep, a multiplicity and two types), we shouldn't need to</span><span>
</span><span id="line-1551"></span><span>    </span><span class="hs-comment">-- explicitly unify the runtime reps here; unifying the types themselves</span><span>
</span><span id="line-1552"></span><span>    </span><span class="hs-comment">-- should be sufficient.  See Note [Representation of function types].</span><span>
</span><span id="line-1553"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853633"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680853633"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621680853632"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853632"><span class="hs-identifier hs-var">co_mult</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621680853631"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853631"><span class="hs-identifier hs-var">co1</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680853630"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853630"><span class="hs-identifier hs-var">co2</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Maybe (TyCon, [Coercion])
</span><a href="GHC.Core.Coercion.html#splitTyConAppCo_maybe"><span class="hs-identifier hs-var">splitTyConAppCo_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853636"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1554"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680853633"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.Prim.html#funTyCon"><span class="hs-identifier hs-var">funTyCon</span></a></span><span>
</span><span id="line-1555"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span id="local-6989586621680853621"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853621"><span class="hs-identifier hs-var">lkcos</span></a></span></span><span> </span><span id="local-6989586621680853620"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853620"><span class="hs-identifier hs-var">rkcos</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Pair Coercion) -&gt; [Coercion] -&gt; Pair [Coercion]
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Type -&gt; Coercion) -&gt; Pair Type -&gt; Pair Coercion
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">(Pair Type -&gt; Pair Coercion)
-&gt; (Coercion -&gt; Pair Type) -&gt; Coercion -&gt; Pair Coercion
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Pair Type
</span><a href="GHC.Core.Coercion.html#coercionKind"><span class="hs-identifier hs-var">coercionKind</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853632"><span class="hs-identifier hs-var">co_mult</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853631"><span class="hs-identifier hs-var">co1</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853630"><span class="hs-identifier hs-var">co2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1556"></span><span>    </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; [Type]
-&gt; [Coercion]
-&gt; [Coercion]
-&gt; [Coercion]
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match_args"><span class="hs-identifier hs-var">ty_co_match_args</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853642"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853641"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853639"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853638"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853637"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853632"><span class="hs-identifier hs-var">co_mult</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853631"><span class="hs-identifier hs-var">co1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853630"><span class="hs-identifier hs-var">co2</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853621"><span class="hs-identifier hs-var">lkcos</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853620"><span class="hs-identifier hs-var">rkcos</span></a></span><span>
</span><span id="line-1557"></span><span>
</span><span id="line-1558"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span id="local-6989586621680853617"><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853617"><span class="hs-identifier hs-var">menv</span></a></span></span><span> </span><span id="local-6989586621680853616"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853616"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllTy"><span class="hs-identifier hs-type">ForAllTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-type">Bndr</span></a></span><span> </span><span id="local-6989586621680853615"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853615"><span class="hs-identifier hs-var">tv1</span></a></span></span><span> </span><span class="annot"><span class="annottext">ArgFlag
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680853614"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853614"><span class="hs-identifier hs-var">ty1</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1559"></span><span>                       </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllCo"><span class="hs-identifier hs-type">ForAllCo</span></a></span><span> </span><span id="local-6989586621680853612"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853612"><span class="hs-identifier hs-var">tv2</span></a></span></span><span> </span><span id="local-6989586621680853611"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853611"><span class="hs-identifier hs-var">kind_co2</span></a></span></span><span> </span><span id="local-6989586621680853610"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853610"><span class="hs-identifier hs-var">co2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1560"></span><span>                       </span><span id="local-6989586621680853609"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853609"><span class="hs-identifier hs-var">lkco</span></a></span></span><span> </span><span id="local-6989586621680853608"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853608"><span class="hs-identifier hs-var">rkco</span></a></span></span><span>
</span><span id="line-1561"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853615"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">OutTyVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853612"><span class="hs-identifier hs-var">tv2</span></a></span><span>
</span><span id="line-1562"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680853606"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853606"><span class="hs-identifier hs-var">subst1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; Coercion
-&gt; Coercion
-&gt; Coercion
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853617"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853616"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OutTyVar -&gt; Type
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853615"><span class="hs-identifier hs-var">tv1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853611"><span class="hs-identifier hs-var">kind_co2</span></a></span><span>
</span><span id="line-1563"></span><span>                               </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853604"><span class="hs-identifier hs-var">ki_ki_co</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853604"><span class="hs-identifier hs-var">ki_ki_co</span></a></span><span>
</span><span id="line-1564"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680853603"><span class="annot"><span class="annottext">rn_env0 :: RnEnv2
</span><a href="#local-6989586621680853603"><span class="hs-identifier hs-var hs-var">rn_env0</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MatchEnv -&gt; RnEnv2
</span><a href="GHC.Core.Unify.html#me_env"><span class="hs-identifier hs-var hs-var">me_env</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853617"><span class="hs-identifier hs-var">menv</span></a></span><span>
</span><span id="line-1565"></span><span>             </span><span id="local-6989586621680853602"><span class="annot"><span class="annottext">rn_env1 :: RnEnv2
</span><a href="#local-6989586621680853602"><span class="hs-identifier hs-var hs-var">rn_env1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RnEnv2 -&gt; OutTyVar -&gt; OutTyVar -&gt; RnEnv2
</span><a href="GHC.Types.Var.Env.html#rnBndr2"><span class="hs-identifier hs-var">rnBndr2</span></a></span><span> </span><span class="annot"><span class="annottext">RnEnv2
</span><a href="#local-6989586621680853603"><span class="hs-identifier hs-var">rn_env0</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853615"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853612"><span class="hs-identifier hs-var">tv2</span></a></span><span>
</span><span id="line-1566"></span><span>             </span><span id="local-6989586621680853600"><span class="annot"><span class="annottext">menv' :: MatchEnv
</span><a href="#local-6989586621680853600"><span class="hs-identifier hs-var hs-var">menv'</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853617"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">me_env :: RnEnv2
</span><a href="GHC.Core.Unify.html#me_env"><span class="hs-identifier hs-var">me_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RnEnv2
</span><a href="#local-6989586621680853602"><span class="hs-identifier hs-var">rn_env1</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1567"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; Coercion
-&gt; Coercion
-&gt; Coercion
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853600"><span class="hs-identifier hs-var">menv'</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853606"><span class="hs-identifier hs-var">subst1</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853614"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853610"><span class="hs-identifier hs-var">co2</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853609"><span class="hs-identifier hs-var">lkco</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853608"><span class="hs-identifier hs-var">rkco</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1568"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1569"></span><span>    </span><span id="local-6989586621680853604"><span class="annot"><span class="annottext">ki_ki_co :: Coercion
</span><a href="#local-6989586621680853604"><span class="hs-identifier hs-var hs-var">ki_ki_co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.html#liftedTypeKind"><span class="hs-identifier hs-var">liftedTypeKind</span></a></span><span>
</span><span id="line-1570"></span><span>
</span><span id="line-1571"></span><span class="hs-comment">-- ty_co_match menv subst (ForAllTy (Bndr cv1 _) ty1)</span><span>
</span><span id="line-1572"></span><span class="hs-comment">--                        (ForAllCo cv2 kind_co2 co2)</span><span>
</span><span id="line-1573"></span><span class="hs-comment">--                        lkco rkco</span><span>
</span><span id="line-1574"></span><span class="hs-comment">--   | isCoVar cv1 &amp;&amp; isCoVar cv2</span><span>
</span><span id="line-1575"></span><span class="hs-comment">--   We seems not to have enough information for this case</span><span>
</span><span id="line-1576"></span><span class="hs-comment">--   1. Given:</span><span>
</span><span id="line-1577"></span><span class="hs-comment">--        cv1      :: (s1 :: k1) ~r (s2 :: k2)</span><span>
</span><span id="line-1578"></span><span class="hs-comment">--        kind_co2 :: (s1' ~ s2') ~N (t1 ~ t2)</span><span>
</span><span id="line-1579"></span><span class="hs-comment">--        eta1      = mkNthCo role 2 (downgradeRole r Nominal kind_co2)</span><span>
</span><span id="line-1580"></span><span class="hs-comment">--                 :: s1' ~ t1</span><span>
</span><span id="line-1581"></span><span class="hs-comment">--        eta2      = mkNthCo role 3 (downgradeRole r Nominal kind_co2)</span><span>
</span><span id="line-1582"></span><span class="hs-comment">--                 :: s2' ~ t2</span><span>
</span><span id="line-1583"></span><span class="hs-comment">--      Wanted:</span><span>
</span><span id="line-1584"></span><span class="hs-comment">--        subst1 &lt;- ty_co_match menv subst  s1 eta1 kco1 kco2</span><span>
</span><span id="line-1585"></span><span class="hs-comment">--        subst2 &lt;- ty_co_match menv subst1 s2 eta2 kco3 kco4</span><span>
</span><span id="line-1586"></span><span class="hs-comment">--      Question: How do we get kcoi?</span><span>
</span><span id="line-1587"></span><span class="hs-comment">--   2. Given:</span><span>
</span><span id="line-1588"></span><span class="hs-comment">--        lkco :: &lt;*&gt;    -- See Note [Weird typing rule for ForAllTy] in GHC.Core.TyCo.Rep</span><span>
</span><span id="line-1589"></span><span class="hs-comment">--        rkco :: &lt;*&gt;</span><span>
</span><span id="line-1590"></span><span class="hs-comment">--      Wanted:</span><span>
</span><span id="line-1591"></span><span class="hs-comment">--        ty_co_match menv' subst2 ty1 co2 lkco' rkco'</span><span>
</span><span id="line-1592"></span><span class="hs-comment">--      Question: How do we get lkco' and rkco'?</span><span>
</span><span id="line-1593"></span><span>
</span><span id="line-1594"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680853599"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853599"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionTy"><span class="hs-identifier hs-type">CoercionTy</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-1595"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; Maybe CvSubstEnv
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853599"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-comment">-- don't inspect coercions</span><span>
</span><span id="line-1596"></span><span>
</span><span id="line-1597"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span id="local-6989586621680853598"><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853598"><span class="hs-identifier hs-var">menv</span></a></span></span><span> </span><span id="local-6989586621680853597"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853597"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680853596"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853596"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#GRefl"><span class="hs-identifier hs-type">GRefl</span></a></span><span> </span><span id="local-6989586621680853594"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680853594"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span id="local-6989586621680853593"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853593"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#MCo"><span class="hs-identifier hs-type">MCo</span></a></span><span> </span><span id="local-6989586621680853591"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853591"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680853590"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853590"><span class="hs-identifier hs-var">lkco</span></a></span></span><span> </span><span id="local-6989586621680853589"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853589"><span class="hs-identifier hs-var">rkco</span></a></span></span><span>
</span><span id="line-1598"></span><span>  </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; Coercion
-&gt; Coercion
-&gt; Coercion
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853598"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853597"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853596"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; Type -&gt; MCoercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Rep.html#GRefl"><span class="hs-identifier hs-var">GRefl</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680853594"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853593"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">MCoercion
</span><a href="GHC.Core.TyCo.Rep.html#MRefl"><span class="hs-identifier hs-var">MRefl</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853590"><span class="hs-identifier hs-var">lkco</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853589"><span class="hs-identifier hs-var">rkco</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkTransCo"><span class="hs-operator hs-var">`mkTransCo`</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkSymCo"><span class="hs-identifier hs-var">mkSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853591"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1599"></span><span>
</span><span id="line-1600"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span id="local-6989586621680853587"><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853587"><span class="hs-identifier hs-var">menv</span></a></span></span><span> </span><span id="local-6989586621680853586"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853586"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680853585"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853585"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680853584"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853584"><span class="hs-identifier hs-var">co1</span></a></span></span><span> </span><span id="local-6989586621680853583"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853583"><span class="hs-identifier hs-var">lkco</span></a></span></span><span> </span><span id="local-6989586621680853582"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853582"><span class="hs-identifier hs-var">rkco</span></a></span></span><span>
</span><span id="line-1601"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CastTy"><span class="hs-identifier hs-type">CastTy</span></a></span><span> </span><span id="local-6989586621680853581"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853581"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621680853580"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853580"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853579"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680853579"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Maybe (Type, Role)
</span><a href="GHC.Core.Coercion.html#isReflCo_maybe"><span class="hs-identifier hs-var">isReflCo_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853584"><span class="hs-identifier hs-var">co1</span></a></span><span>
</span><span id="line-1602"></span><span>  </span><span class="hs-comment">-- In @pushRefl@, pushing reflexive coercion inside CastTy will give us</span><span>
</span><span id="line-1603"></span><span>  </span><span class="hs-comment">-- t |&gt; co ~ t ; &lt;t&gt; ; t ~ t |&gt; co</span><span>
</span><span id="line-1604"></span><span>  </span><span class="hs-comment">-- But transitive coercions are not helpful. Therefore we deal</span><span>
</span><span id="line-1605"></span><span>  </span><span class="hs-comment">-- with it here: we do recursion on the smaller reflexive coercion,</span><span>
</span><span id="line-1606"></span><span>  </span><span class="hs-comment">-- while propagating the correct kind coercions.</span><span>
</span><span id="line-1607"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680853578"><span class="annot"><span class="annottext">kco' :: Coercion
</span><a href="#local-6989586621680853578"><span class="hs-identifier hs-var hs-var">kco'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkSymCo"><span class="hs-identifier hs-var">mkSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853580"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1608"></span><span>    </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; Coercion
-&gt; Coercion
-&gt; Coercion
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853587"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853586"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853585"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkReflCo"><span class="hs-identifier hs-var">mkReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680853579"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853581"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853583"><span class="hs-identifier hs-var">lkco</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkTransCo"><span class="hs-operator hs-var">`mkTransCo`</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853578"><span class="hs-identifier hs-var">kco'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1609"></span><span>                                                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853582"><span class="hs-identifier hs-var">rkco</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkTransCo"><span class="hs-operator hs-var">`mkTransCo`</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853578"><span class="hs-identifier hs-var">kco'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1610"></span><span>
</span><span id="line-1611"></span><span>
</span><span id="line-1612"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span id="local-6989586621680853576"><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853576"><span class="hs-identifier hs-var">menv</span></a></span></span><span> </span><span id="local-6989586621680853575"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853575"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680853574"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853574"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680853573"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853573"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621680853572"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853572"><span class="hs-identifier hs-var">lkco</span></a></span></span><span> </span><span id="local-6989586621680853571"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853571"><span class="hs-identifier hs-var">rkco</span></a></span></span><span>
</span><span id="line-1613"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680853570"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853570"><span class="hs-identifier hs-var">co'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Maybe Coercion
</span><a href="GHC.Core.Unify.html#pushRefl"><span class="hs-identifier hs-var">pushRefl</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853573"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; Coercion
-&gt; Coercion
-&gt; Coercion
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853576"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853575"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853574"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853570"><span class="hs-identifier hs-var">co'</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853572"><span class="hs-identifier hs-var">lkco</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853571"><span class="hs-identifier hs-var">rkco</span></a></span><span>
</span><span id="line-1614"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe CvSubstEnv
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1615"></span><span>
</span><span id="line-1616"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match_tc"><span class="hs-identifier hs-type">ty_co_match_tc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#MatchEnv"><span class="hs-identifier hs-type">MatchEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#LiftCoEnv"><span class="hs-identifier hs-type">LiftCoEnv</span></a></span><span>
</span><span id="line-1617"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1618"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1619"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#LiftCoEnv"><span class="hs-identifier hs-type">LiftCoEnv</span></a></span><span>
</span><span id="line-1620"></span><span id="ty_co_match_tc"><span class="annot"><span class="annottext">ty_co_match_tc :: MatchEnv
-&gt; CvSubstEnv
-&gt; TyCon
-&gt; [Type]
-&gt; TyCon
-&gt; [Coercion]
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match_tc"><span class="hs-identifier hs-var hs-var">ty_co_match_tc</span></a></span></span><span> </span><span id="local-6989586621680853568"><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853568"><span class="hs-identifier hs-var">menv</span></a></span></span><span> </span><span id="local-6989586621680853567"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853567"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680853566"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680853566"><span class="hs-identifier hs-var">tc1</span></a></span></span><span> </span><span id="local-6989586621680853565"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853565"><span class="hs-identifier hs-var">tys1</span></a></span></span><span> </span><span id="local-6989586621680853564"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680853564"><span class="hs-identifier hs-var">tc2</span></a></span></span><span> </span><span id="local-6989586621680853563"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853563"><span class="hs-identifier hs-var">cos2</span></a></span></span><span>
</span><span id="line-1621"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Maybe ()
forall (f :: * -&gt; *). Alternative f =&gt; Bool -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#guard"><span class="hs-identifier hs-var">guard</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680853566"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680853564"><span class="hs-identifier hs-var">tc2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1622"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; [Type]
-&gt; [Coercion]
-&gt; [Coercion]
-&gt; [Coercion]
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match_args"><span class="hs-identifier hs-var">ty_co_match_args</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853568"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853567"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853565"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853563"><span class="hs-identifier hs-var">cos2</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853562"><span class="hs-identifier hs-var">lkcos</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853561"><span class="hs-identifier hs-var">rkcos</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1623"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1624"></span><span>    </span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span id="local-6989586621680853562"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853562"><span class="hs-identifier hs-var">lkcos</span></a></span></span><span> </span><span id="local-6989586621680853561"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853561"><span class="hs-identifier hs-var">rkcos</span></a></span></span><span>
</span><span id="line-1625"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Pair Coercion) -&gt; [Coercion] -&gt; Pair [Coercion]
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Type -&gt; Coercion) -&gt; Pair Type -&gt; Pair Coercion
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">(Pair Type -&gt; Pair Coercion)
-&gt; (Coercion -&gt; Pair Type) -&gt; Coercion -&gt; Pair Coercion
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Pair Type
</span><a href="GHC.Core.Coercion.html#coercionKind"><span class="hs-identifier hs-var">coercionKind</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853563"><span class="hs-identifier hs-var">cos2</span></a></span><span>
</span><span id="line-1626"></span><span>
</span><span id="line-1627"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match_app"><span class="hs-identifier hs-type">ty_co_match_app</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#MatchEnv"><span class="hs-identifier hs-type">MatchEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#LiftCoEnv"><span class="hs-identifier hs-type">LiftCoEnv</span></a></span><span>
</span><span id="line-1628"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1629"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#LiftCoEnv"><span class="hs-identifier hs-type">LiftCoEnv</span></a></span><span>
</span><span id="line-1630"></span><span id="ty_co_match_app"><span class="annot"><span class="annottext">ty_co_match_app :: MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; [Type]
-&gt; Coercion
-&gt; [Coercion]
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match_app"><span class="hs-identifier hs-var hs-var">ty_co_match_app</span></a></span></span><span> </span><span id="local-6989586621680853557"><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853557"><span class="hs-identifier hs-var">menv</span></a></span></span><span> </span><span id="local-6989586621680853556"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853556"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680853555"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853555"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621680853554"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853554"><span class="hs-identifier hs-var">ty1args</span></a></span></span><span> </span><span id="local-6989586621680853553"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853553"><span class="hs-identifier hs-var">co2</span></a></span></span><span> </span><span id="local-6989586621680853552"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853552"><span class="hs-identifier hs-var">co2args</span></a></span></span><span>
</span><span id="line-1631"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853551"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853551"><span class="hs-identifier hs-var">ty1'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853550"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853550"><span class="hs-identifier hs-var">ty1a</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (Type, Type)
Type -&gt; Maybe (Type, Type)
</span><a href="GHC.Core.Type.html#repSplitAppTy_maybe"><span class="hs-identifier hs-var">repSplitAppTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853555"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1632"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853549"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853549"><span class="hs-identifier hs-var">co2'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853548"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853548"><span class="hs-identifier hs-var">co2a</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Maybe (Coercion, Coercion)
</span><a href="GHC.Core.Coercion.html#splitAppCo_maybe"><span class="hs-identifier hs-var">splitAppCo_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853553"><span class="hs-identifier hs-var">co2</span></a></span><span>
</span><span id="line-1633"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; [Type]
-&gt; Coercion
-&gt; [Coercion]
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match_app"><span class="hs-identifier hs-var">ty_co_match_app</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853557"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853556"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853551"><span class="hs-identifier hs-var">ty1'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853550"><span class="hs-identifier hs-var">ty1a</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; [Type] -&gt; [Type]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853554"><span class="hs-identifier hs-var">ty1args</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853549"><span class="hs-identifier hs-var">co2'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853548"><span class="hs-identifier hs-var">co2a</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; [Coercion] -&gt; [Coercion]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853552"><span class="hs-identifier hs-var">co2args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1634"></span><span>
</span><span id="line-1635"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1636"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680853547"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853547"><span class="hs-identifier hs-var">subst1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; Coercion
-&gt; Coercion
-&gt; Coercion
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853557"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853556"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853546"><span class="hs-identifier hs-var">ki1</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853545"><span class="hs-identifier hs-var">ki2</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853544"><span class="hs-identifier hs-var">ki_ki_co</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853544"><span class="hs-identifier hs-var">ki_ki_co</span></a></span><span>
</span><span id="line-1637"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span id="local-6989586621680853542"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853542"><span class="hs-identifier hs-var">lkco</span></a></span></span><span> </span><span id="local-6989586621680853541"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853541"><span class="hs-identifier hs-var">rkco</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Coercion) -&gt; Pair Type -&gt; Pair Coercion
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Pair Type
</span><a href="GHC.Core.Coercion.html#coercionKind"><span class="hs-identifier hs-var">coercionKind</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853545"><span class="hs-identifier hs-var">ki2</span></a></span><span>
</span><span id="line-1638"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621680853540"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853540"><span class="hs-identifier hs-var">subst2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; Coercion
-&gt; Coercion
-&gt; Coercion
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853557"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853547"><span class="hs-identifier hs-var">subst1</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853555"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853553"><span class="hs-identifier hs-var">co2</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853542"><span class="hs-identifier hs-var">lkco</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853541"><span class="hs-identifier hs-var">rkco</span></a></span><span>
</span><span id="line-1639"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span id="local-6989586621680853536"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853536"><span class="hs-identifier hs-var">lkcos</span></a></span></span><span> </span><span id="local-6989586621680853535"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853535"><span class="hs-identifier hs-var">rkcos</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Pair Coercion) -&gt; [Coercion] -&gt; Pair [Coercion]
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Type -&gt; Coercion) -&gt; Pair Type -&gt; Pair Coercion
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">(Pair Type -&gt; Pair Coercion)
-&gt; (Coercion -&gt; Pair Type) -&gt; Coercion -&gt; Pair Coercion
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Pair Type
</span><a href="GHC.Core.Coercion.html#coercionKind"><span class="hs-identifier hs-var">coercionKind</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853552"><span class="hs-identifier hs-var">co2args</span></a></span><span>
</span><span id="line-1640"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; [Type]
-&gt; [Coercion]
-&gt; [Coercion]
-&gt; [Coercion]
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match_args"><span class="hs-identifier hs-var">ty_co_match_args</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853557"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853540"><span class="hs-identifier hs-var">subst2</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853554"><span class="hs-identifier hs-var">ty1args</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853552"><span class="hs-identifier hs-var">co2args</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853536"><span class="hs-identifier hs-var">lkcos</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853535"><span class="hs-identifier hs-var">rkcos</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1641"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1642"></span><span>    </span><span id="local-6989586621680853546"><span class="annot"><span class="annottext">ki1 :: Type
</span><a href="#local-6989586621680853546"><span class="hs-identifier hs-var hs-var">ki1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Type
Type -&gt; Type
</span><a href="GHC.Core.Type.html#typeKind"><span class="hs-identifier hs-var">typeKind</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853555"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1643"></span><span>    </span><span id="local-6989586621680853545"><span class="annot"><span class="annottext">ki2 :: Coercion
</span><a href="#local-6989586621680853545"><span class="hs-identifier hs-var hs-var">ki2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#promoteCoercion"><span class="hs-identifier hs-var">promoteCoercion</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853553"><span class="hs-identifier hs-var">co2</span></a></span><span>
</span><span id="line-1644"></span><span>    </span><span id="local-6989586621680853544"><span class="annot"><span class="annottext">ki_ki_co :: Coercion
</span><a href="#local-6989586621680853544"><span class="hs-identifier hs-var hs-var">ki_ki_co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.html#liftedTypeKind"><span class="hs-identifier hs-var">liftedTypeKind</span></a></span><span>
</span><span id="line-1645"></span><span>
</span><span id="line-1646"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match_args"><span class="hs-identifier hs-type">ty_co_match_args</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#MatchEnv"><span class="hs-identifier hs-type">MatchEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#LiftCoEnv"><span class="hs-identifier hs-type">LiftCoEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1647"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1648"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html#LiftCoEnv"><span class="hs-identifier hs-type">LiftCoEnv</span></a></span><span>
</span><span id="line-1649"></span><span id="ty_co_match_args"><span class="annot"><span class="annottext">ty_co_match_args :: MatchEnv
-&gt; CvSubstEnv
-&gt; [Type]
-&gt; [Coercion]
-&gt; [Coercion]
-&gt; [Coercion]
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match_args"><span class="hs-identifier hs-var hs-var">ty_co_match_args</span></a></span></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><span class="hs-identifier">_</span></span><span>    </span><span id="local-6989586621680853533"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853533"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>       </span><span class="hs-special">[</span><span class="hs-special">]</span><span>         </span><span class="annot"><span class="annottext">[Coercion]
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CvSubstEnv -&gt; Maybe CvSubstEnv
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853533"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-1650"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match_args"><span class="hs-identifier hs-var">ty_co_match_args</span></a></span><span> </span><span id="local-6989586621680853532"><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853532"><span class="hs-identifier hs-var">menv</span></a></span></span><span> </span><span id="local-6989586621680853531"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853531"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853530"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853530"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680853529"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853529"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853528"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853528"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680853527"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853527"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853526"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853526"><span class="hs-identifier hs-var">lkco</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680853525"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853525"><span class="hs-identifier hs-var">lkcos</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680853524"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853524"><span class="hs-identifier hs-var">rkco</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680853523"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853523"><span class="hs-identifier hs-var">rkcos</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1651"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680853522"><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853522"><span class="hs-identifier hs-var">subst'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; Type
-&gt; Coercion
-&gt; Coercion
-&gt; Coercion
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match"><span class="hs-identifier hs-var">ty_co_match</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853532"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853531"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853530"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853528"><span class="hs-identifier hs-var">arg</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853526"><span class="hs-identifier hs-var">lkco</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853524"><span class="hs-identifier hs-var">rkco</span></a></span><span>
</span><span id="line-1652"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">MatchEnv
-&gt; CvSubstEnv
-&gt; [Type]
-&gt; [Coercion]
-&gt; [Coercion]
-&gt; [Coercion]
-&gt; Maybe CvSubstEnv
</span><a href="GHC.Core.Unify.html#ty_co_match_args"><span class="hs-identifier hs-var">ty_co_match_args</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><a href="#local-6989586621680853532"><span class="hs-identifier hs-var">menv</span></a></span><span> </span><span class="annot"><span class="annottext">CvSubstEnv
</span><a href="#local-6989586621680853522"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853529"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853527"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853525"><span class="hs-identifier hs-var">lkcos</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621680853523"><span class="hs-identifier hs-var">rkcos</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1653"></span><span class="annot"><a href="GHC.Core.Unify.html#ty_co_match_args"><span class="hs-identifier hs-var">ty_co_match_args</span></a></span><span> </span><span class="annot"><span class="annottext">MatchEnv
</span><span class="hs-identifier">_</span></span><span>    </span><span class="annot"><span class="annottext">CvSubstEnv
</span><span class="hs-identifier">_</span></span><span>     </span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span>        </span><span class="annot"><span class="annottext">[Coercion]
</span><span class="hs-identifier">_</span></span><span>          </span><span class="annot"><span class="annottext">[Coercion]
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe CvSubstEnv
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1654"></span><span>
</span><span id="line-1655"></span><span class="annot"><a href="GHC.Core.Unify.html#pushRefl"><span class="hs-identifier hs-type">pushRefl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-1656"></span><span id="pushRefl"><span class="annot"><span class="annottext">pushRefl :: Coercion -&gt; Maybe Coercion
</span><a href="GHC.Core.Unify.html#pushRefl"><span class="hs-identifier hs-var hs-var">pushRefl</span></a></span></span><span> </span><span id="local-6989586621680853521"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853521"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1657"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Maybe (Type, Role)
</span><a href="GHC.Core.Coercion.html#isReflCo_maybe"><span class="hs-identifier hs-var">isReflCo_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680853521"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1658"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppTy"><span class="hs-identifier hs-type">AppTy</span></a></span><span> </span><span id="local-6989586621680853520"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853520"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621680853519"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853519"><span class="hs-identifier hs-var">ty2</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1659"></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Maybe Coercion
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Rep.html#AppCo"><span class="hs-identifier hs-var">AppCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkReflCo"><span class="hs-identifier hs-var">mkReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853520"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853519"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1660"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680853518"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853518"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span id="local-6989586621680853517"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853517"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621680853516"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853516"><span class="hs-identifier hs-var">ty2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853515"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680853515"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1661"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680853514"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853514"><span class="hs-identifier hs-var">rep1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe Type
Type -&gt; Maybe Type
</span><a href="GHC.Core.Type.html#getRuntimeRep_maybe"><span class="hs-identifier hs-var">getRuntimeRep_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853517"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1662"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680853512"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853512"><span class="hs-identifier hs-var">rep2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe Type
Type -&gt; Maybe Type
</span><a href="GHC.Core.Type.html#getRuntimeRep_maybe"><span class="hs-identifier hs-var">getRuntimeRep_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853516"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1663"></span><span>      </span><span class="hs-glyph">-&gt;</span><span>  </span><span class="annot"><span class="annottext">Coercion -&gt; Maybe Coercion
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; TyCon -&gt; [Coercion] -&gt; Coercion
</span><a href="GHC.Core.TyCo.Rep.html#TyConAppCo"><span class="hs-identifier hs-var">TyConAppCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680853515"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.Prim.html#funTyCon"><span class="hs-identifier hs-var">funTyCon</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#multToCo"><span class="hs-identifier hs-var">multToCo</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853518"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Role -&gt; Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkReflCo"><span class="hs-identifier hs-var">mkReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680853515"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853514"><span class="hs-identifier hs-var">rep1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Role -&gt; Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkReflCo"><span class="hs-identifier hs-var">mkReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680853515"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853512"><span class="hs-identifier hs-var">rep2</span></a></span><span>
</span><span id="line-1664"></span><span>                                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Role -&gt; Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkReflCo"><span class="hs-identifier hs-var">mkReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680853515"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853517"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">,</span><span>  </span><span class="annot"><span class="annottext">Role -&gt; Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkReflCo"><span class="hs-identifier hs-var">mkReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680853515"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853516"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1665"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621680853510"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680853510"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621680853509"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853509"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853508"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680853508"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1666"></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Maybe Coercion
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; TyCon -&gt; [Coercion] -&gt; Coercion
</span><a href="GHC.Core.TyCo.Rep.html#TyConAppCo"><span class="hs-identifier hs-var">TyConAppCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680853508"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680853510"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Role -&gt; Type -&gt; Coercion) -&gt; [Role] -&gt; [Type] -&gt; [Coercion]
forall a b c. (a -&gt; b -&gt; c) -&gt; [a] -&gt; [b] -&gt; [c]
</span><a href="../../base/src/GHC.List.html#zipWith"><span class="hs-identifier hs-var">zipWith</span></a></span><span> </span><span class="annot"><span class="annottext">Role -&gt; Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkReflCo"><span class="hs-identifier hs-var">mkReflCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; TyCon -&gt; [Role]
</span><a href="GHC.Core.Coercion.html#tyConRolesX"><span class="hs-identifier hs-var">tyConRolesX</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680853508"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680853510"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680853509"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1667"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllTy"><span class="hs-identifier hs-type">ForAllTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-type">Bndr</span></a></span><span> </span><span id="local-6989586621680853505"><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853505"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="annot"><span class="annottext">ArgFlag
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680853504"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853504"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680853503"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680853503"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1668"></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Maybe Coercion
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OutTyVar -&gt; Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.TyCo.Rep.html#ForAllCo"><span class="hs-identifier hs-var">ForAllCo</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853505"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OutTyVar -&gt; Type
</span><a href="GHC.Types.Var.html#varType"><span class="hs-identifier hs-var hs-var">varType</span></a></span><span> </span><span class="annot"><span class="annottext">OutTyVar
</span><a href="#local-6989586621680853505"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkReflCo"><span class="hs-identifier hs-var">mkReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621680853503"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680853504"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1669"></span><span>    </span><span class="hs-comment">-- NB: NoRefl variant. Otherwise, we get a loop!</span><span>
</span><span id="line-1670"></span><span>    </span><span class="annot"><span class="annottext">Maybe (Type, Role)
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Coercion
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1671"></span></pre></body></html>